JBoss Rich Faces SVN: r17641 - in root/core/branches/jsr-330: bom and 5 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-18 20:01:14 -0400 (Fri, 18 Jun 2010)
New Revision: 17641
Added:
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/jsr330/
root/core/branches/jsr-330/impl/src/test/resources/META-INF/services/
Removed:
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java
root/core/branches/jsr-330/jsr330-impl/
Modified:
root/core/branches/jsr-330/bom/pom.xml
root/core/branches/jsr-330/impl/pom.xml
root/core/branches/jsr-330/pom.xml
Log:
merge jsr-330 module to implementation
Modified: root/core/branches/jsr-330/bom/pom.xml
===================================================================
--- root/core/branches/jsr-330/bom/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
+++ root/core/branches/jsr-330/bom/pom.xml 2010-06-19 00:01:14 UTC (rev 17641)
@@ -62,11 +62,6 @@
<artifactId>richfaces-core-impl</artifactId>
<version>${project.version}</version>
</dependency>
- <dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>jsr330-impl</artifactId>
- <version>${project.version}</version>
- </dependency>
<!-- Required for EL-CSS func -->
<dependency>
Modified: root/core/branches/jsr-330/impl/pom.xml
===================================================================
--- root/core/branches/jsr-330/impl/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
+++ root/core/branches/jsr-330/impl/pom.xml 2010-06-19 00:01:14 UTC (rev 17641)
@@ -45,10 +45,6 @@
<artifactId>richfaces-commons-api</artifactId>
</dependency>
<dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>jsr330-impl</artifactId>
- </dependency>
- <dependency>
<groupId>net.sourceforge.cssparser</groupId>
<artifactId>cssparser</artifactId>
</dependency>
@@ -56,6 +52,10 @@
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ </dependency>
<!-- Provided Dependencies -->
<dependency>
Copied: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330 (from rev 17639, root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330)
Deleted: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -1,55 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.jsr330;
-
-import javax.inject.Provider;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public interface Binder<T> {
-
-
- public Binder<T> to(Class<? extends T> implementation);
-
- public Binder<T> toInstance(T value);
-
- public Binder<T> toProvider(Class<? extends Provider<T>> provaderImplementation);
-
- public Binder<T> toProviderInstance(Provider<T> provider);
-
- public Binder<T> toService();
-
- public Binder<T> toService(Class<? extends T> defaultImplementation);
-
- public Binder<T> asSingleton();
- public Binder<T> asSessionScope();
- public Binder<T> asRequestScope();
- public Binder<T> asApplicationScope();
-
-}
Copied: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java (from rev 17640, root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java)
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java (rev 0)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Binder.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -0,0 +1,65 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.jsr330;
+
+import javax.inject.Provider;
+
+/**
+ * <p class="changed_added_4_0">
+ * This interface lets {@link Module} to register concrete implementation of service.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ * @param T
+ * type of object provided by binder
+ *
+ */
+public interface Binder<T> {
+
+ public Binder<T> to(Class<? extends T> implementation);
+
+ public Binder<T> toInstance(T value);
+
+ public Binder<T> toProvider(Class<? extends Provider<T>> provaderImplementation);
+
+ public Binder<T> toProviderInstance(Provider<T> provider);
+
+ public Binder<T> toService();
+
+ public Binder<T> toService(Class<? extends T> defaultImplementation);
+
+ public Binder<T> asSingleton();
+
+ public Binder<T> asSessionScope();
+
+ public Binder<T> asRequestScope();
+
+ public Binder<T> asApplicationScope();
+
+ public abstract Binder<T> asComponentScope();
+
+ public abstract Binder<T> asContexScope();
+
+}
Deleted: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -1,330 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.jsr330;
-
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.locks.ReentrantReadWriteLock;
-
-import javax.faces.context.FacesContext;
-import javax.inject.Provider;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- * @param <T>
- */
-public final class BinderImpl<T> implements Binder<T> {
-
- private final Scope<T> defaultScope = new Scope<T>() {
- public T get() {
- return getProvider().get();
- }
- };
-
- private final Scope<T> singltonScope = new Scope<T>() {
-
- private volatile boolean instantiated = false;
-
- private volatile T value;
-
- public T get() {
- if (!instantiated) {
- value = getProvider().get();
- instantiated = true;
- }
- return value;
- }
- };
-
- private abstract class FacesScope implements Scope<T> {
-
- private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
-
- public T get() {
- T value;
- rwLock.readLock().lock();
- try {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- if (null != facesContext) {
- Map<String, Object> map = getMap(facesContext);
- String key = target.toString();
- value = (T) map.get(key);
- if(null == value){
- rwLock.readLock().unlock();
- rwLock.writeLock().lock();
- try {
- value = getProvider().get();
- map.put(key, value);
- } finally {
- rwLock.readLock().lock();
- rwLock.writeLock().unlock();
- }
- }
- } else {
- value = getProvider().get();
- }
- } finally {
- rwLock.readLock().unlock();
- }
- return value;
- }
-
- protected abstract Map<String, Object> getMap(FacesContext facesContext);
- }
-
- private final Scope<T> sessionScope = new FacesScope() {
-
- @Override
- protected Map<String, Object> getMap(FacesContext facesContext) {
- Map<String, Object> map = facesContext.getExternalContext().getSessionMap();
- return map;
- }
- };
-
- private final Scope<T> requestScope = new FacesScope() {
- @Override
- protected Map<String, Object> getMap(FacesContext facesContext) {
- return facesContext.getExternalContext().getRequestMap();
- }
- };
-
- private final Scope<T> applicationScope = new FacesScope() {
- @Override
- protected Map<String, Object> getMap(FacesContext facesContext) {
- return facesContext.getExternalContext().getApplicationMap();
- }
- };
-
- private final Target target;
-
- private Provider<T> provider;
-
- private Provider<Provider<T>> providerOfProvider;
-
- private Scope<T> scope;
-
- private volatile BinderImpl<Provider<T>> providerBinder;
-
- private boolean initialized = false;
-
- /**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @param target
- * the target to set
- */
- public BinderImpl(Target target) {
- this.target = target;
- this.scope = defaultScope;
- }
-
- public T get() {
- checkInitialized();
- return scope.get();
- }
-
- public BinderImpl<Provider<T>> asProviderBinder() {
- if (null == providerBinder) {
- createProviderBinding();
- }
- return providerBinder;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binder#to(java.lang.Class)
- */
- public Binder<T> to(Class<? extends T> implementation) {
- this.provider = new DynamicProvider<T>(implementation);
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binder#toInstance(java.lang.Object)
- */
- public Binder<T> toInstance(final T value) {
- checkNotInitialized();
- this.provider = new Provider<T>() {
-
- public T get() {
- return value;
- }
- };
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binder#toProvider(java.lang.Class)
- */
- @SuppressWarnings("unchecked")
- public Binder<T> toProvider(Class<? extends Provider<T>> providerImplementation) {
- checkNotInitialized();
- this.providerOfProvider = new DynamicProvider(providerImplementation);
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binder#toProviderInstance(javax.inject.Provider)
- */
- public Binder<T> toProviderInstance(Provider<T> provider) {
- this.provider = provider;
- return this;
- }
-
- public Binder<T> toService() {
- Collection<Class<? extends T>> service = loadService();
- if (service.size() > 0) {
- this.to(service.iterator().next());
- } else {
- throw new DependencyException("No implementation found for service " + target);
- }
- return this;
- }
-
- public Binder<T> toService(Class<? extends T> defaultImplementation) {
- Collection<Class<? extends T>> service = loadService();
- if (service.size() > 0) {
- this.to(service.iterator().next());
- } else {
- this.to(defaultImplementation);
- }
- return this;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binder#asSingleton()
- */
- public Binder<T> asSingleton() {
- this.scope = singltonScope;
- return this;
- }
-
- public Binder<T> asApplicationScope() {
- this.scope = applicationScope;
- return this;
- }
-
- public Binder<T> asRequestScope() {
- this.scope = requestScope;
- return this;
- }
-
- public Binder<T> asSessionScope() {
- this.scope = sessionScope;
- return this;
- }
-
- void init(Binders injector) throws DependencyException {
- checkNotInitialized();
- if (null == provider && null == providerOfProvider) {
- throw new DependencyException("binding not has not been set");
- }
- if (null != provider && provider instanceof Initializable) {
- if( ((Initializable) provider).init(injector)){
- this.scope = singltonScope;
- }
- }
- if (null != providerOfProvider && providerOfProvider instanceof Initializable) {
- ((Initializable) providerOfProvider).init(injector);
- }
- this.initialized = true;
- }
-
- void createInstances(Binders injector) throws DependencyException {
- checkInitialized();
- if (null == provider && null != providerOfProvider) {
- this.provider = providerOfProvider.get();
- }
- if (this.scope == singltonScope ) {
- scope.get();
- }
- createProviderBinding();
- }
-
- public void destroy(InjectorImpl injectorImpl) {
- if (null != provider && provider instanceof Initializable) {
- ((Initializable) provider).destroy();
- }
- if (null != providerOfProvider && providerOfProvider instanceof Initializable) {
- ((Initializable) providerOfProvider).destroy();
- }
- provider = null;
- providerOfProvider = null;
- providerBinder = null;
- this.initialized = false;
- }
-
- Provider<T> getProvider() {
- return null == this.provider ? this.providerOfProvider.get() : this.provider;
- }
-
- private void checkInitialized() {
- if (!initialized) {
- throw new DependencyException("Dependency injection implementation has not been initialized");
- }
- }
-
- private void checkNotInitialized() {
- if (initialized) {
- throw new DependencyException("Dependency injection implementation has already been initialized");
- }
- }
-
- @SuppressWarnings("unchecked")
- private void createProviderBinding() {
- BinderImpl<Provider<T>> providerBinder = new BinderImpl(target.toProvider());
- if (null != provider) {
- providerBinder.toInstance(provider);
- } else if (null != providerOfProvider) {
- providerBinder.toProviderInstance(providerOfProvider);
- }
- providerBinder.initialized = true;
- this.providerBinder = providerBinder;
- }
-
- private Collection<Class<? extends T>> loadService() {
- if (null == target) {
- throw new DependencyException("Binder does not configured correctly");
- }
- try {
- return ServiceLoader.<T> loadServiceClasses((Class<T>) target.getRawType());
- } catch (ServiceException e) {
- throw new DependencyException("Error loading service ", e);
- }
- }
-}
Copied: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java (from rev 17640, root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java)
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java (rev 0)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -0,0 +1,398 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.jsr330;
+
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.locks.ReentrantReadWriteLock;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.inject.Provider;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ * @param <T>
+ */
+public final class BinderImpl<T> implements Binder<T> {
+
+ private final Scope<T> defaultScope = new Scope<T>() {
+ public T get() {
+ return getProvider().get();
+ }
+ };
+
+ private final Scope<T> singltonScope = new Scope<T>() {
+
+ private volatile boolean instantiated = false;
+
+ private volatile T value;
+
+ public T get() {
+ if (!instantiated) {
+ value = getProvider().get();
+ instantiated = true;
+ }
+ return value;
+ }
+ };
+
+ /**
+ * <p class="changed_added_4_0">
+ * This is base class for JSF single-thread scopes ( request, view, FacesContext attributes )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ private abstract class FacesScope implements Scope<T> {
+
+ @SuppressWarnings("unchecked")
+ public T get() {
+ T value;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != facesContext) {
+ Map map = getMap(facesContext);
+ String key = target.toKey();
+ value = (T) map.get(key);
+ if (null == value) {
+ value = getProvider().get();
+ map.put(key, value);
+ }
+ } else {
+ value = getProvider().get();
+ }
+ return value;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected abstract Map getMap(FacesContext facesContext);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * This class represent scopes that can be shared between threads, like application, singleton or session. For
+ * thread-safety, it uses {@link ReentrantReadWriteLock} to insert object instance into scope map.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ private abstract class ThreadSafeFacesScope implements Scope<T> {
+
+ private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
+
+ @SuppressWarnings("unchecked")
+ public T get() {
+ T value;
+ rwLock.readLock().lock();
+ try {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != facesContext) {
+ Map<String, Object> map = getMap(facesContext);
+ String key = target.toKey();
+ value = (T) map.get(key);
+ if (null == value) {
+ rwLock.readLock().unlock();
+ rwLock.writeLock().lock();
+ try {
+ value = getProvider().get();
+ map.put(key, value);
+ } finally {
+ rwLock.readLock().lock();
+ rwLock.writeLock().unlock();
+ }
+ }
+ } else {
+ value = getProvider().get();
+ }
+ } finally {
+ rwLock.readLock().unlock();
+ }
+ return value;
+ }
+
+ protected abstract Map<String, Object> getMap(FacesContext facesContext);
+ }
+
+ private final Scope<T> sessionScope = new ThreadSafeFacesScope() {
+
+ @Override
+ protected Map<String, Object> getMap(FacesContext facesContext) {
+ Map<String, Object> map = facesContext.getExternalContext().getSessionMap();
+ return map;
+ }
+ };
+
+ private final Scope<T> requestScope = new FacesScope() {
+ @Override
+ protected Map<String, Object> getMap(FacesContext facesContext) {
+ return facesContext.getExternalContext().getRequestMap();
+ }
+ };
+
+ private final Scope<T> contextScope = new FacesScope() {
+ @Override
+ protected Map<Object, Object> getMap(FacesContext facesContext) {
+ return facesContext.getAttributes();
+ }
+ };
+
+ private final Scope<T> componentScope = new FacesScope() {
+ @SuppressWarnings("unchecked")
+ @Override
+ protected Map<String, Object> getMap(FacesContext facesContext) {
+ Map<String, Object> map =
+ (Map<String, Object>) facesContext.getAttributes().get(UIComponent.CURRENT_COMPONENT);
+ if (null == map) {
+ throw new DependencyException("Current component is not set for dependency target " + target.toString());
+ }
+ return map;
+ }
+ };
+ private final Scope<T> applicationScope = new ThreadSafeFacesScope() {
+ @Override
+ protected Map<String, Object> getMap(FacesContext facesContext) {
+ return facesContext.getExternalContext().getApplicationMap();
+ }
+ };
+
+ private final Target target;
+
+ private Provider<T> provider;
+
+ private Provider<Provider<T>> providerOfProvider;
+
+ private Scope<T> scope;
+
+ private volatile Binder<Provider<T>> providerBinder;
+
+ private boolean initialized = false;
+
+ /**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @param target
+ * the target to set
+ */
+ public BinderImpl(Target target) {
+ this.target = target;
+ this.scope = defaultScope;
+ }
+
+ public T get() {
+ checkInitialized();
+ return scope.get();
+ }
+
+ public Binder<Provider<T>> asProviderBinder() {
+ if (null == providerBinder) {
+ createProviderBinding();
+ }
+ return providerBinder;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binder#to(java.lang.Class)
+ */
+ public Binder<T> to(Class<? extends T> implementation) {
+ this.provider = new DynamicProvider<T>(implementation);
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binder#toInstance(java.lang.Object)
+ */
+ public Binder<T> toInstance(final T value) {
+ checkNotInitialized();
+ this.provider = new Provider<T>() {
+
+ public T get() {
+ return value;
+ }
+ };
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binder#toProvider(java.lang.Class)
+ */
+ @SuppressWarnings("unchecked")
+ public Binder<T> toProvider(Class<? extends Provider<T>> providerImplementation) {
+ checkNotInitialized();
+ this.providerOfProvider = new DynamicProvider(providerImplementation);
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binder#toProviderInstance(javax.inject.Provider)
+ */
+ public Binder<T> toProviderInstance(Provider<T> provider) {
+ this.provider = provider;
+ return this;
+ }
+
+ public Binder<T> toService() {
+ Collection<Class<? extends T>> service = loadService();
+ if (service.size() > 0) {
+ this.to(service.iterator().next());
+ } else {
+ throw new DependencyException("No implementation found for service " + target);
+ }
+ return this;
+ }
+
+ public Binder<T> toService(Class<? extends T> defaultImplementation) {
+ Collection<Class<? extends T>> service = loadService();
+ if (service.size() > 0) {
+ this.to(service.iterator().next());
+ } else {
+ this.to(defaultImplementation);
+ }
+ return this;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binder#asSingleton()
+ */
+ public Binder<T> asSingleton() {
+ this.scope = singltonScope;
+ return this;
+ }
+
+ public Binder<T> asApplicationScope() {
+ this.scope = applicationScope;
+ return this;
+ }
+
+ public Binder<T> asRequestScope() {
+ this.scope = requestScope;
+ return this;
+ }
+
+ public Binder<T> asSessionScope() {
+ this.scope = sessionScope;
+ return this;
+ }
+
+ public Binder<T> asContexScope() {
+ this.scope = contextScope;
+ return this;
+ }
+
+ public Binder<T> asComponentScope() {
+ this.scope = componentScope;
+ return this;
+ }
+
+ void init(Binders injector) throws DependencyException {
+ checkNotInitialized();
+ if (null == provider && null == providerOfProvider) {
+ throw new DependencyException("binding not has not been set");
+ }
+ if (null != provider && provider instanceof Initializable) {
+ if (((Initializable) provider).init(injector)) {
+ this.scope = singltonScope;
+ }
+ }
+ if (null != providerOfProvider && providerOfProvider instanceof Initializable) {
+ ((Initializable) providerOfProvider).init(injector);
+ }
+ this.initialized = true;
+ }
+
+ void createInstances(Binders injector) throws DependencyException {
+ checkInitialized();
+ if (null == provider && null != providerOfProvider) {
+ this.provider = providerOfProvider.get();
+ }
+ if (this.scope == singltonScope) {
+ scope.get();
+ }
+ createProviderBinding();
+ }
+
+ public void destroy(InjectorImpl injectorImpl) {
+ if (null != provider && provider instanceof Initializable) {
+ ((Initializable) provider).destroy();
+ }
+ if (null != providerOfProvider && providerOfProvider instanceof Initializable) {
+ ((Initializable) providerOfProvider).destroy();
+ }
+ provider = null;
+ providerOfProvider = null;
+ providerBinder = null;
+ this.initialized = false;
+ }
+
+ Provider<T> getProvider() {
+ return null == this.provider ? this.providerOfProvider.get() : this.provider;
+ }
+
+ private void checkInitialized() {
+ if (!initialized) {
+ throw new DependencyException("Dependency injection implementation has not been initialized");
+ }
+ }
+
+ private void checkNotInitialized() {
+ if (initialized) {
+ throw new DependencyException("Dependency injection implementation has already been initialized");
+ }
+ }
+
+ private void createProviderBinding() {
+ BinderImpl<Provider<T>> providerBinder = new BinderImpl<Provider<T>>(target.toProvider());
+ providerBinder.toInstance(scope);
+ providerBinder.initialized = true;
+ this.providerBinder = providerBinder;
+ }
+
+ @SuppressWarnings("unchecked")
+ private Collection<Class<? extends T>> loadService() {
+ if (null == target) {
+ throw new DependencyException("Binder does not configured correctly");
+ }
+ try {
+ return ServiceLoader.<T> loadServiceClasses((Class<T>) target.getRawType());
+ } catch (ServiceException e) {
+ throw new DependencyException("Error loading service ", e);
+ }
+ }
+}
Deleted: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -1,137 +0,0 @@
-package org.richfaces.jsr330;
-
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import javax.inject.Provider;
-
-import org.richfaces.application.DependencyInjector;
-
-/**
- * <p class="changed_added_4_0">
- * Lightweight implementation for JSR-330 dependency injection. Supports only {@link javax.inject.Named} annotations, no
- * scopes except {@link javax.inject.Singleton}
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class InjectorImpl implements DependencyInjector, Binders, InjectorConfig {
-
- private final Map<Target, BinderImpl<?>> bindings = new ConcurrentHashMap<Target, BinderImpl<?>>();
-
- @SuppressWarnings("unchecked")
- public <T> T create(Class<T> type, String name) {
- Target target = Target.create(name, type);
- return (T) getBinding(target).get();
- }
-
- public <T> T create(Class<T> type) {
- return create(type, null);
- }
-
- public void init(Module... modules) {
- register(DependencyInjector.class).toInstance(this);
- for (Module bindingModule : modules) {
- bindingModule.configure(this);
- }
- initProviders();
- initSingletons();
- }
-
- public void destroy() {
- for (BinderImpl<?> binding : bindings.values()) {
- binding.destroy(this);
- }
- bindings.clear();
- }
-
- private void initSingletons() {
- Collection<BinderImpl<?>> values = new ArrayList<BinderImpl<?>>(bindings.values());
- for (BinderImpl<?> binding : values) {
- binding.createInstances(this);
- }
- }
-
- private void initProviders() {
- Collection<BinderImpl<?>> values = new ArrayList<BinderImpl<?>>(bindings.values());
- for (BinderImpl<?> binding : values) {
- binding.init(this);
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.Binders#getBinding(org.richfaces.jsr330.Target)
- */
- @SuppressWarnings("unchecked")
- public BinderImpl<?> getBinding(Target type) {
- if (bindings.containsKey(type)) {
- return bindings.get(type);
- } else if (type.isConcrete()) {
- // Concrete classes can be created without configuration.
- BinderImpl binding = new BinderImpl(type);
- binding.to(type.getRawType());
- binding.init(this);
- binding.createInstances(this);
- registerBinding(type, binding);
- return binding;
- } else if (type.isProvider()) {
- return getBinding(type.toProviderTarget()).asProviderBinder();
- } else {
- throw new DependencyException("Type " + type + " has not been registered");
- }
- }
-
- @SuppressWarnings("unchecked")
- public void inject(Object value) {
- Target target = Target.create(value.getClass());
- Provider<?> provider = getBinding(target).getProvider();
- if (provider instanceof DynamicProvider) {
- try {
- ((DynamicProvider) provider).inject(value);
- } catch (Exception e) {
- throw new DependencyException("Cannot inject dependencies into object " + value, e);
- }
- }
-
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.InjectorConfig#register(org.richfaces.jsr330.Target)
- */
- @SuppressWarnings("unchecked")
- public <T> Binder<T> register(Target type) {
- BinderImpl<T> binding = new BinderImpl(type);
- registerBinding(type, binding);
- return binding;
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.InjectorConfig#register(java.lang.Class, java.lang.Class)
- */
- public <T> Binder<T> register(Class<T> type, Class<?>... typeArguments) {
- return register(Target.create(type, typeArguments));
- }
-
- /*
- * (non-Javadoc)
- *
- * @see org.richfaces.jsr330.InjectorConfig#register(java.lang.String, java.lang.Class, java.lang.Class)
- */
- public <T> Binder<T> register(String name, Class<T> type, Class<?>... typeArguments) {
- return register(Target.create(name, type, typeArguments));
- }
-
- private void registerBinding(Target type, BinderImpl<?> binder) {
- bindings.put(type, binder);
- }
-}
Copied: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java (from rev 17640, root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java)
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java (rev 0)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -0,0 +1,137 @@
+package org.richfaces.jsr330;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.inject.Provider;
+
+import org.richfaces.application.DependencyInjector;
+
+/**
+ * <p class="changed_added_4_0">
+ * Lightweight implementation for JSR-330 dependency injection. Supports only {@link javax.inject.Named} annotations, no
+ * scopes except {@link javax.inject.Singleton}
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class InjectorImpl implements DependencyInjector, Binders, InjectorConfig {
+
+ private final Map<Target, BinderImpl<?>> bindings = new ConcurrentHashMap<Target, BinderImpl<?>>();
+
+ @SuppressWarnings("unchecked")
+ public <T> T create(Class<T> type, String name) {
+ Target target = Target.create(name, type);
+ return (T) getBinding(target).get();
+ }
+
+ public <T> T create(Class<T> type) {
+ return create(type, null);
+ }
+
+ public void init(Module... modules) {
+ register(DependencyInjector.class).toInstance(this);
+ for (Module bindingModule : modules) {
+ bindingModule.configure(this);
+ }
+ initProviders();
+ initSingletons();
+ }
+
+ public void destroy() {
+ for (BinderImpl<?> binding : bindings.values()) {
+ binding.destroy(this);
+ }
+ bindings.clear();
+ }
+
+ private void initSingletons() {
+ Collection<BinderImpl<?>> values = new ArrayList<BinderImpl<?>>(bindings.values());
+ for (BinderImpl<?> binding : values) {
+ binding.createInstances(this);
+ }
+ }
+
+ private void initProviders() {
+ Collection<BinderImpl<?>> values = new ArrayList<BinderImpl<?>>(bindings.values());
+ for (BinderImpl<?> binding : values) {
+ binding.init(this);
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.Binders#getBinding(org.richfaces.jsr330.Target)
+ */
+ @SuppressWarnings("unchecked")
+ public BinderImpl<?> getBinding(Target type) {
+ if (bindings.containsKey(type)) {
+ return bindings.get(type);
+ } else if (type.isConcrete()) {
+ // Concrete classes can be created without configuration.
+ BinderImpl binding = new BinderImpl(type);
+ binding.to(type.getRawType());
+ binding.init(this);
+ binding.createInstances(this);
+ registerBinding(type, binding);
+ return binding;
+ } else if (type.isProvider()) {
+ return (BinderImpl<?>) getBinding(type.toProviderTarget()).asProviderBinder();
+ } else {
+ throw new DependencyException("Type " + type + " has not been registered");
+ }
+ }
+
+ @SuppressWarnings("unchecked")
+ public void inject(Object value) {
+ Target target = Target.create(value.getClass());
+ Provider<?> provider = getBinding(target).getProvider();
+ if (provider instanceof DynamicProvider) {
+ try {
+ ((DynamicProvider) provider).inject(value);
+ } catch (Exception e) {
+ throw new DependencyException("Cannot inject dependencies into object " + value, e);
+ }
+ }
+
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.InjectorConfig#register(org.richfaces.jsr330.Target)
+ */
+ @SuppressWarnings("unchecked")
+ public <T> Binder<T> register(Target type) {
+ BinderImpl<T> binding = new BinderImpl(type);
+ registerBinding(type, binding);
+ return binding;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.InjectorConfig#register(java.lang.Class, java.lang.Class)
+ */
+ public <T> Binder<T> register(Class<T> type, Class<?>... typeArguments) {
+ return register(Target.create(type, typeArguments));
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.richfaces.jsr330.InjectorConfig#register(java.lang.String, java.lang.Class, java.lang.Class)
+ */
+ public <T> Binder<T> register(String name, Class<T> type, Class<?>... typeArguments) {
+ return register(Target.create(name, type, typeArguments));
+ }
+
+ private void registerBinding(Target type, BinderImpl<?> binder) {
+ bindings.put(type, binder);
+ }
+}
Deleted: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -1,203 +0,0 @@
-/*
- * $Id$
- *
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library 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 library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.jsr330;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Modifier;
-import java.lang.reflect.ParameterizedType;
-import java.lang.reflect.Type;
-import java.util.Arrays;
-
-import javax.inject.Named;
-import javax.inject.Provider;
-
-/**
- * <p class="changed_added_4_0">
- * </p>
- *
- * @author asmirnov(a)exadel.com
- *
- */
-public class Target {
-
- private static final Class<?>[] EMPTY_TYPES = new Class<?>[]{};
-
- private final String name;
-
- private final Type type;
-
- private Class<?> rawType;
-
- private Type[] actualTypeArguments;
-
- public Target(Type type) {
- this(null,type);
- }
-
- public Target(String name, Type type) {
- this.type = type;
- this.name = name;
- this.rawType = getRawClass(type);
- this.actualTypeArguments = getActualTypeArguments(type);
- }
-
- public static Target create(Class<?> type, Class<?> ...typeArguments) {
- return create(null, type, typeArguments);
- }
-
- public static Target create(String name, Class<?> type, Class<?> ...typeArguments) {
- Target target = new Target(name, type);
- target.actualTypeArguments = typeArguments;
- return target;
- }
-
- public static Target createNamed(Type type, Annotation... annotations) {
- if (null != annotations) {
- for (Annotation annotation : annotations) {
- if (annotation instanceof Named) {
- return new Target(((Named) annotation).value(), type);
- }
- }
-
- }
- return new Target(type);
- }
-
- public Target toProvider() {
- Target target = new Target(name, type);
- target.rawType = Provider.class;
- target.actualTypeArguments = new Type[]{this.type};
- return target;
- }
-
- public Target toProviderTarget(){
- if(isProvider()){
- return new Target(name,this.actualTypeArguments[0]);
- } else {
- throw new DependencyException("Type "+this+" not is a Provider type");
- }
- }
-
- public boolean isProvider(){
- return Provider.class.isAssignableFrom(rawType) && (1==actualTypeArguments.length);
- }
-
- public boolean isConcrete() {
- return !Modifier.isAbstract((getRawType()).getModifiers());
- }
-
- public Class<?> getRawType(){
- return rawType;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#hashCode()
- */
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Arrays.hashCode(this.actualTypeArguments);
- result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
- result = prime * result + ((this.rawType == null) ? 0 : this.rawType.hashCode());
- return result;
- }
-
- /* (non-Javadoc)
- * @see java.lang.Object#equals(java.lang.Object)
- */
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- Target other = (Target) obj;
- if (!Arrays.equals(this.actualTypeArguments, other.actualTypeArguments)) {
- return false;
- }
- if (this.name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!this.name.equals(other.name)) {
- return false;
- }
- if (!this.rawType.equals(other.rawType)) {
- return false;
- }
- return true;
- }
-
- public static Type[] getActualTypeArguments(Type type) {
- if(type instanceof Class<?>){
- return EMPTY_TYPES;
- } else if(type instanceof ParameterizedType){
- return ((ParameterizedType) type).getActualTypeArguments();
- } else {
- throw new DependencyException("Unknown type "+type);
- }
- }
-
- public static Class<?> getRawClass(Type type){
- if(type instanceof Class<?>){
- return (Class<?>)type;
- } else if(type instanceof ParameterizedType){
- return getRawClass(((ParameterizedType) type).getRawType());
- } else {
- throw new DependencyException("Unknown type "+type);
- }
-
- }
-
- /**
- * <p class="changed_added_4_0"></p>
- * @return the actualTypeArguments
- */
- public Type[] getActualTypeArguments() {
- return this.actualTypeArguments;
- }
-
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder();
- builder.append(rawType.getName());
- if(getActualTypeArguments().length>0){
- builder.append("< ");
- for (Type argument : getActualTypeArguments()) {
- builder.append(getRawClass(argument).getSimpleName()).append(' ');
- }
- builder.append('>');
- }
- if(null != name){
- builder.append(" :").append(name);
- }
- return builder.toString();
- }
-}
Copied: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java (from rev 17640, root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java)
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java (rev 0)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/jsr330/Target.java 2010-06-19 00:01:14 UTC (rev 17641)
@@ -0,0 +1,210 @@
+/*
+ * $Id$
+ *
+ * License Agreement.
+ *
+ * Rich Faces - Natural Ajax for Java Server Faces (JSF)
+ *
+ * Copyright (C) 2007 Exadel, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation.
+ *
+ * This library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+package org.richfaces.jsr330;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Modifier;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+
+import javax.inject.Named;
+import javax.inject.Provider;
+
+/**
+ * <p class="changed_added_4_0">
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+public class Target {
+
+ private static final Class<?>[] EMPTY_TYPES = new Class<?>[]{};
+
+ private final String name;
+
+ private final Type type;
+
+ private final Class<?> rawType;
+
+ private Type[] actualTypeArguments;
+
+ public Target(Type type) {
+ this(null,type);
+ }
+
+ public Target(String name, Type type) {
+ this.type = type;
+ this.name = name;
+ this.rawType = getRawClass(type);
+ this.actualTypeArguments = getActualTypeArguments(type);
+ }
+
+ public static Target create(Class<?> type, Class<?> ...typeArguments) {
+ return create(null, type, typeArguments);
+ }
+
+ public static Target create(String name, Class<?> type, Class<?> ...typeArguments) {
+ Target target = new Target(name, type);
+ target.actualTypeArguments = typeArguments;
+ return target;
+ }
+
+ public static Target createNamed(Type type, Annotation... annotations) {
+ if (null != annotations) {
+ for (Annotation annotation : annotations) {
+ if (annotation instanceof Named) {
+ return new Target(((Named) annotation).value(), type);
+ }
+ }
+
+ }
+ return new Target(type);
+ }
+
+ public Target toProvider() {
+ Target target = new Target(name, Provider.class);
+ target.actualTypeArguments = new Type[]{this.type};
+ return target;
+ }
+
+ public Target toProviderTarget(){
+ if(isProvider()){
+ return new Target(name,this.actualTypeArguments[0]);
+ } else {
+ throw new DependencyException("Type "+this+" not is a Provider type");
+ }
+ }
+
+ public boolean isProvider(){
+ return Provider.class.isAssignableFrom(rawType) && (1==actualTypeArguments.length);
+ }
+
+ public boolean isConcrete() {
+ return !Modifier.isAbstract((getRawType()).getModifiers());
+ }
+
+ public Class<?> getRawType(){
+ return rawType;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#hashCode()
+ */
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Arrays.hashCode(this.actualTypeArguments);
+ result = prime * result + ((this.name == null) ? 0 : this.name.hashCode());
+ result = prime * result + ((this.rawType == null) ? 0 : this.rawType.hashCode());
+ return result;
+ }
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#equals(java.lang.Object)
+ */
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ Target other = (Target) obj;
+ if (!Arrays.equals(this.actualTypeArguments, other.actualTypeArguments)) {
+ return false;
+ }
+ if (this.name == null) {
+ if (other.name != null) {
+ return false;
+ }
+ } else if (!this.name.equals(other.name)) {
+ return false;
+ }
+ if (!this.rawType.equals(other.rawType)) {
+ return false;
+ }
+ return true;
+ }
+
+ public static Type[] getActualTypeArguments(Type type) {
+ if(type instanceof Class<?>){
+ return EMPTY_TYPES;
+ } else if(type instanceof ParameterizedType){
+ return ((ParameterizedType) type).getActualTypeArguments();
+ } else {
+ throw new DependencyException("Unknown type "+type);
+ }
+ }
+
+ public static Class<?> getRawClass(Type type){
+ if(type instanceof Class<?>){
+ return (Class<?>)type;
+ } else if(type instanceof ParameterizedType){
+ return getRawClass(((ParameterizedType) type).getRawType());
+ } else {
+ throw new DependencyException("Unknown type "+type);
+ }
+
+ }
+
+ /**
+ * <p class="changed_added_4_0"></p>
+ * @return the actualTypeArguments
+ */
+ public Type[] getActualTypeArguments() {
+ return this.actualTypeArguments;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(rawType.getName());
+ if(getActualTypeArguments().length>0){
+ builder.append("< ");
+ for (Type argument : getActualTypeArguments()) {
+ builder.append(getRawClass(argument).getSimpleName()).append(' ');
+ }
+ builder.append('>');
+ }
+ if(null != name){
+ builder.append(" :").append(name);
+ }
+ return builder.toString();
+ }
+
+ public String toKey() {
+ if(null != name){
+ return name;
+ } else {
+ return toString();
+ }
+ }
+}
Copied: root/core/branches/jsr-330/impl/src/test/java/org/richfaces/jsr330 (from rev 17639, root/core/branches/jsr-330/jsr330-impl/src/test/java/org/richfaces/jsr330)
Copied: root/core/branches/jsr-330/impl/src/test/resources/META-INF/services (from rev 17639, root/core/branches/jsr-330/jsr330-impl/src/test/resources/META-INF/services)
Modified: root/core/branches/jsr-330/pom.xml
===================================================================
--- root/core/branches/jsr-330/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
+++ root/core/branches/jsr-330/pom.xml 2010-06-19 00:01:14 UTC (rev 17641)
@@ -39,7 +39,6 @@
<module>bom</module>
<module>parent</module>
<module>api</module>
- <module>jsr330-impl</module>
<module>impl</module>
</modules>
14 years, 6 months
JBoss Rich Faces SVN: r17640 - in root: core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330 and 28 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-18 15:14:03 -0400 (Fri, 18 Jun 2010)
New Revision: 17640
Modified:
root/commons/trunk/api/
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java
root/docs/trunk/
root/docs/trunk/Component_Reference/
root/docs/trunk/Developer_Guide/
root/docs/trunk/Migration_Guide/
root/examples/iteration-demo/trunk/
root/examples/misc-demo/trunk/
root/ui/core/trunk/
root/ui/core/trunk/parent/
root/ui/core/trunk/parent/pom.xml
root/ui/core/trunk/ui/
root/ui/core/trunk/ui/pom.xml
root/ui/dist/trunk/richfaces-components-api/
root/ui/dist/trunk/richfaces-components-impl/
root/ui/dist/trunk/richfaces-components-ui/
root/ui/iteration/trunk/datascroller/
root/ui/iteration/trunk/datascroller/ui/pom.xml
root/ui/iteration/trunk/dist/
root/ui/iteration/trunk/dist/richfaces-ui-iteration-api/
root/ui/iteration/trunk/dist/richfaces-ui-iteration-impl/
root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui/
root/ui/iteration/trunk/parent/
root/ui/iteration/trunk/parent/pom.xml
root/ui/iteration/trunk/tables/
root/ui/iteration/trunk/tables/api/
root/ui/iteration/trunk/tables/impl/
root/ui/iteration/trunk/tables/ui/
root/ui/iteration/trunk/tables/ui/pom.xml
root/ui/misc/trunk/
root/ui/misc/trunk/componentcontrol/
root/ui/misc/trunk/componentcontrol/pom.xml
root/ui/misc/trunk/dist/richfaces-ui-misc-ui/
root/ui/misc/trunk/functions/
root/ui/misc/trunk/functions/pom.xml
root/ui/misc/trunk/parent/pom.xml
Log:
set targets and eclipse files to svn:ignore, add new scopes
Property changes on: root/commons/trunk/api
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.project
.classpath
.clover
Modified: root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Binder.java 2010-06-18 19:14:03 UTC (rev 17640)
@@ -27,14 +27,17 @@
/**
* <p class="changed_added_4_0">
+ * This interface lets {@link Module} to register concrete implementation of service.
* </p>
*
* @author asmirnov(a)exadel.com
*
+ * @param T
+ * type of object provided by binder
+ *
*/
public interface Binder<T> {
-
public Binder<T> to(Class<? extends T> implementation);
public Binder<T> toInstance(T value);
@@ -48,8 +51,15 @@
public Binder<T> toService(Class<? extends T> defaultImplementation);
public Binder<T> asSingleton();
+
public Binder<T> asSessionScope();
+
public Binder<T> asRequestScope();
+
public Binder<T> asApplicationScope();
-
+
+ public abstract Binder<T> asComponentScope();
+
+ public abstract Binder<T> asContexScope();
+
}
Modified: root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-18 19:14:03 UTC (rev 17640)
@@ -27,6 +27,7 @@
import java.util.Map;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
import javax.inject.Provider;
@@ -61,10 +62,52 @@
}
};
+ /**
+ * <p class="changed_added_4_0">
+ * This is base class for JSF single-thread scopes ( request, view, FacesContext attributes )
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
private abstract class FacesScope implements Scope<T> {
+ @SuppressWarnings("unchecked")
+ public T get() {
+ T value;
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ if (null != facesContext) {
+ Map map = getMap(facesContext);
+ String key = target.toKey();
+ value = (T) map.get(key);
+ if (null == value) {
+ value = getProvider().get();
+ map.put(key, value);
+ }
+ } else {
+ value = getProvider().get();
+ }
+ return value;
+ }
+
+ @SuppressWarnings("unchecked")
+ protected abstract Map getMap(FacesContext facesContext);
+ }
+
+ /**
+ * <p class="changed_added_4_0">
+ * This class represent scopes that can be shared between threads, like application, singleton or session. For
+ * thread-safety, it uses {@link ReentrantReadWriteLock} to insert object instance into scope map.
+ * </p>
+ *
+ * @author asmirnov(a)exadel.com
+ *
+ */
+ private abstract class ThreadSafeFacesScope implements Scope<T> {
+
private ReentrantReadWriteLock rwLock = new ReentrantReadWriteLock();
+ @SuppressWarnings("unchecked")
public T get() {
T value;
rwLock.readLock().lock();
@@ -72,9 +115,9 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
if (null != facesContext) {
Map<String, Object> map = getMap(facesContext);
- String key = target.toString();
+ String key = target.toKey();
value = (T) map.get(key);
- if(null == value){
+ if (null == value) {
rwLock.readLock().unlock();
rwLock.writeLock().lock();
try {
@@ -96,9 +139,9 @@
protected abstract Map<String, Object> getMap(FacesContext facesContext);
}
-
- private final Scope<T> sessionScope = new FacesScope() {
-
+
+ private final Scope<T> sessionScope = new ThreadSafeFacesScope() {
+
@Override
protected Map<String, Object> getMap(FacesContext facesContext) {
Map<String, Object> map = facesContext.getExternalContext().getSessionMap();
@@ -112,10 +155,29 @@
return facesContext.getExternalContext().getRequestMap();
}
};
-
- private final Scope<T> applicationScope = new FacesScope() {
+
+ private final Scope<T> contextScope = new FacesScope() {
@Override
+ protected Map<Object, Object> getMap(FacesContext facesContext) {
+ return facesContext.getAttributes();
+ }
+ };
+
+ private final Scope<T> componentScope = new FacesScope() {
+ @SuppressWarnings("unchecked")
+ @Override
protected Map<String, Object> getMap(FacesContext facesContext) {
+ Map<String, Object> map =
+ (Map<String, Object>) facesContext.getAttributes().get(UIComponent.CURRENT_COMPONENT);
+ if (null == map) {
+ throw new DependencyException("Current component is not set for dependency target " + target.toString());
+ }
+ return map;
+ }
+ };
+ private final Scope<T> applicationScope = new ThreadSafeFacesScope() {
+ @Override
+ protected Map<String, Object> getMap(FacesContext facesContext) {
return facesContext.getExternalContext().getApplicationMap();
}
};
@@ -128,7 +190,7 @@
private Scope<T> scope;
- private volatile BinderImpl<Provider<T>> providerBinder;
+ private volatile Binder<Provider<T>> providerBinder;
private boolean initialized = false;
@@ -149,7 +211,7 @@
return scope.get();
}
- public BinderImpl<Provider<T>> asProviderBinder() {
+ public Binder<Provider<T>> asProviderBinder() {
if (null == providerBinder) {
createProviderBinding();
}
@@ -249,13 +311,23 @@
return this;
}
+ public Binder<T> asContexScope() {
+ this.scope = contextScope;
+ return this;
+ }
+
+ public Binder<T> asComponentScope() {
+ this.scope = componentScope;
+ return this;
+ }
+
void init(Binders injector) throws DependencyException {
checkNotInitialized();
if (null == provider && null == providerOfProvider) {
throw new DependencyException("binding not has not been set");
}
if (null != provider && provider instanceof Initializable) {
- if( ((Initializable) provider).init(injector)){
+ if (((Initializable) provider).init(injector)) {
this.scope = singltonScope;
}
}
@@ -270,7 +342,7 @@
if (null == provider && null != providerOfProvider) {
this.provider = providerOfProvider.get();
}
- if (this.scope == singltonScope ) {
+ if (this.scope == singltonScope) {
scope.get();
}
createProviderBinding();
@@ -305,18 +377,14 @@
}
}
- @SuppressWarnings("unchecked")
private void createProviderBinding() {
- BinderImpl<Provider<T>> providerBinder = new BinderImpl(target.toProvider());
- if (null != provider) {
- providerBinder.toInstance(provider);
- } else if (null != providerOfProvider) {
- providerBinder.toProviderInstance(providerOfProvider);
- }
+ BinderImpl<Provider<T>> providerBinder = new BinderImpl<Provider<T>>(target.toProvider());
+ providerBinder.toInstance(scope);
providerBinder.initialized = true;
this.providerBinder = providerBinder;
}
+ @SuppressWarnings("unchecked")
private Collection<Class<? extends T>> loadService() {
if (null == target) {
throw new DependencyException("Binder does not configured correctly");
Modified: root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/InjectorImpl.java 2010-06-18 19:14:03 UTC (rev 17640)
@@ -81,7 +81,7 @@
registerBinding(type, binding);
return binding;
} else if (type.isProvider()) {
- return getBinding(type.toProviderTarget()).asProviderBinder();
+ return (BinderImpl<?>) getBinding(type.toProviderTarget()).asProviderBinder();
} else {
throw new DependencyException("Type " + type + " has not been registered");
}
Modified: root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/Target.java 2010-06-18 19:14:03 UTC (rev 17640)
@@ -47,7 +47,7 @@
private final Type type;
- private Class<?> rawType;
+ private final Class<?> rawType;
private Type[] actualTypeArguments;
@@ -85,8 +85,7 @@
}
public Target toProvider() {
- Target target = new Target(name, type);
- target.rawType = Provider.class;
+ Target target = new Target(name, Provider.class);
target.actualTypeArguments = new Type[]{this.type};
return target;
}
@@ -200,4 +199,12 @@
}
return builder.toString();
}
+
+ public String toKey() {
+ if(null != name){
+ return name;
+ } else {
+ return toString();
+ }
+ }
}
Property changes on: root/docs/trunk
___________________________________________________________________
Name: svn:ignore
- target
.settings
.project
.classpath
.clover
+ target
.settings
.project
.classpath
.clover
Property changes on: root/docs/trunk/Component_Reference
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/docs/trunk/Developer_Guide
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/docs/trunk/Migration_Guide
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/examples/iteration-demo/trunk
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/examples/misc-demo/trunk
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/core/trunk
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/core/trunk/parent
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/core/trunk/parent/pom.xml
===================================================================
--- root/ui/core/trunk/parent/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/core/trunk/parent/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -65,6 +65,25 @@
<groupId>org.richfaces.cdk</groupId>
<artifactId>maven-cdk-plugin</artifactId>
<version>${org.richfaces.cdk.version}</version>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <uri>http://richfaces.org/a4j</uri>
+ <shortName>a4j</shortName>
+ <displayName>Core ajax components tags</displayName>
+ </taglib>
+ </library>
+ </configuration>
+ <executions>
+ <execution>
+ <id>cdk-generate-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@@ -106,29 +125,6 @@
</configuration>
</plugin>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <configuration>
- <library>
- <prefix>org.richfaces</prefix>
- <taglib>
- <uri>http://richfaces.org/a4j</uri>
- <shortName>a4j</shortName>
- <displayName>Core ajax components tags</displayName>
- </taglib>
- </library>
- </configuration>
- <executions>
- <execution>
- <id>cdk-generate-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
Property changes on: root/ui/core/trunk/ui
___________________________________________________________________
Name: svn:ignore
- target
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/core/trunk/ui/pom.xml
===================================================================
--- root/ui/core/trunk/ui/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/core/trunk/ui/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -1,120 +1,133 @@
-<!--
- JBoss, Home of Professional Open Source Copyright 2010, Red Hat,
- Inc. 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.
--->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <!--
+ JBoss, Home of Professional Open Source Copyright 2010, Red Hat, Inc.
+ 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.
+ -->
- <parent>
- <groupId>org.richfaces.ui.core</groupId>
- <artifactId>richfaces-ui-core-parent</artifactId>
- <version>4.0.0-SNAPSHOT</version>
- <relativePath>../parent/pom.xml</relativePath>
- </parent>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
- <modelVersion>4.0.0</modelVersion>
- <groupId>org.richfaces.ui.core</groupId>
- <artifactId>richfaces-ui-core-ui</artifactId>
- <name>Richfaces UI Components: Core UI</name>
- <packaging>jar</packaging>
+ <parent>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-parent</artifactId>
+ <version>4.0.0-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
- <dependencies>
- <!-- runtime -->
- <dependency>
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-api</artifactId>
- </dependency>
- <dependency>
- <!-- todo remove this dependency or move to test scope -->
- <groupId>org.richfaces.core</groupId>
- <artifactId>richfaces-core-impl</artifactId>
- </dependency>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.richfaces.ui.core</groupId>
+ <artifactId>richfaces-ui-core-ui</artifactId>
+ <name>Richfaces UI Components: Core UI</name>
+ <packaging>jar</packaging>
- <dependency>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>annotations</artifactId>
- <scope>provided</scope>
- </dependency>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <!-- runtime -->
+ <dependency>
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-api</artifactId>
+ </dependency>
+ <dependency>
+ <!-- todo remove this dependency or move to test scope -->
+ <groupId>org.richfaces.core</groupId>
+ <artifactId>richfaces-core-impl</artifactId>
+ </dependency>
- <!-- JSF with dependencies -->
- <dependency>
- <groupId>${jsf2.api.groupid}</groupId>
- <artifactId>${jsf2.api.artifactid}</artifactId>
- <version>2.0.2</version><!-- TODO: remove this dependency it should inherited from perent poms -->
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>servlet-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet.jsp</groupId>
- <artifactId>jsp-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.el</groupId>
- <artifactId>el-api</artifactId>
- <scope>provided</scope>
- </dependency>
- <dependency>
- <groupId>javax.servlet</groupId>
- <artifactId>jstl</artifactId>
- <scope>provided</scope>
- </dependency>
+ <dependency>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>annotations</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <!-- tests -->
- <dependency>
- <groupId>${jsf2.impl.groupid}</groupId>
- <artifactId>${jsf2.impl.artifactid}</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <!-- todo api? -->
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-jsf</groupId>
- <artifactId>jsf-test-stage</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-jsf</groupId>
- <artifactId>htmlunit-client</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.jboss.test-jsf</groupId>
- <artifactId>jsf-mock</artifactId>
- <scope>test</scope>
- </dependency>
- </dependencies>
+ <!-- JSF with dependencies -->
+ <dependency>
+ <groupId>${jsf2.api.groupid}</groupId>
+ <artifactId>${jsf2.api.artifactid}</artifactId>
+ <version>2.0.2</version>
+ <!--
+ TODO: remove this dependency it should inherited from perent poms
+ -->
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet.jsp</groupId>
+ <artifactId>jsp-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.el</groupId>
+ <artifactId>el-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>jstl</artifactId>
+ <scope>provided</scope>
+ </dependency>
- <scm>
- <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/ui/core/trunk/ui</connection>
- <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root/ui/core/trunk/ui</developerConnection>
- <url>http://fisheye.jboss.org/browse/richfaces</url>
- </scm>
+ <!-- tests -->
+ <dependency>
+ <groupId>${jsf2.impl.groupid}</groupId>
+ <artifactId>${jsf2.impl.artifactid}</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <!-- todo api? -->
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>jsf-test-stage</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>htmlunit-client</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.test-jsf</groupId>
+ <artifactId>jsf-mock</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <scm>
+ <connection>scm:svn:http://anonsvn.jboss.org/repos/richfaces/root/ui/core/trunk/ui
+ </connection>
+ <developerConnection>scm:svn:https://svn.jboss.org/repos/richfaces/root/ui/core/trunk/ui
+ </developerConnection>
+ <url>http://fisheye.jboss.org/browse/richfaces</url>
+ </scm>
</project>
\ No newline at end of file
Property changes on: root/ui/dist/trunk/richfaces-components-api
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/dist/trunk/richfaces-components-impl
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/dist/trunk/richfaces-components-ui
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/datascroller
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/iteration/trunk/datascroller/ui/pom.xml
===================================================================
--- root/ui/iteration/trunk/datascroller/ui/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/iteration/trunk/datascroller/ui/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -34,6 +34,14 @@
<artifactId>datascroller-ui</artifactId>
<name>Richfaces UI Components: Datascroller UI</name>
<packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- runtime -->
Property changes on: root/ui/iteration/trunk/dist
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/dist/richfaces-ui-iteration-api
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/dist/richfaces-ui-iteration-impl
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/dist/richfaces-ui-iteration-ui
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/parent
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/iteration/trunk/parent/pom.xml
===================================================================
--- root/ui/iteration/trunk/parent/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/iteration/trunk/parent/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -62,11 +62,6 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <version>${org.richfaces.cdk.version}</version>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
@@ -82,6 +77,30 @@
<version>2.0-alpha-4</version>
<extensions>true</extensions>
</plugin>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ <version>${org.richfaces.cdk.version}</version>
+ <configuration>
+ <library>
+ <prefix>org.richfaces</prefix>
+ <taglib>
+ <uri>http://richfaces.org/iteration</uri>
+ <shortName>it</shortName>
+ <displayName>Iteration components tags</displayName>
+ </taglib>
+ </library>
+ </configuration>
+ <executions>
+ <execution>
+ <id>cdk-generate-sources</id>
+ <phase>generate-sources</phase>
+ <goals>
+ <goal>generate</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</pluginManagement>
@@ -106,29 +125,6 @@
</configuration>
</plugin>
- <plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <configuration>
- <library>
- <prefix>org.richfaces</prefix>
- <taglib>
- <uri>http://richfaces.org/iteration</uri>
- <shortName>it</shortName>
- <displayName>Iteration components tags</displayName>
- </taglib>
- </library>
- </configuration>
- <executions>
- <execution>
- <id>cdk-generate-sources</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>generate</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
Property changes on: root/ui/iteration/trunk/tables
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/tables/api
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/tables/impl
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/iteration/trunk/tables/ui
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/iteration/trunk/tables/ui/pom.xml
===================================================================
--- root/ui/iteration/trunk/tables/ui/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/iteration/trunk/tables/ui/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -34,6 +34,14 @@
<artifactId>tables-ui</artifactId>
<name>Richfaces UI Components: Tables UI</name>
<packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- runtime -->
Property changes on: root/ui/misc/trunk
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/misc/trunk/componentcontrol
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/misc/trunk/componentcontrol/pom.xml
===================================================================
--- root/ui/misc/trunk/componentcontrol/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/misc/trunk/componentcontrol/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -31,6 +31,14 @@
<artifactId>componentcontrol-ui</artifactId>
<name>Richfaces UI Components: Component control UI</name>
<packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- runtime -->
Property changes on: root/ui/misc/trunk/dist/richfaces-ui-misc-ui
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Property changes on: root/ui/misc/trunk/functions
___________________________________________________________________
Name: svn:ignore
+ target
.settings
.project
.classpath
.clover
Modified: root/ui/misc/trunk/functions/pom.xml
===================================================================
--- root/ui/misc/trunk/functions/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/misc/trunk/functions/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -31,6 +31,14 @@
<artifactId>functions-ui</artifactId>
<name>Richfaces UI Components: Functions UI</name>
<packaging>jar</packaging>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.richfaces.cdk</groupId>
+ <artifactId>maven-cdk-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </build>
<dependencies>
<!-- runtime -->
Modified: root/ui/misc/trunk/parent/pom.xml
===================================================================
--- root/ui/misc/trunk/parent/pom.xml 2010-06-18 18:16:11 UTC (rev 17639)
+++ root/ui/misc/trunk/parent/pom.xml 2010-06-18 19:14:03 UTC (rev 17640)
@@ -72,11 +72,6 @@
<pluginManagement>
<plugins>
<plugin>
- <groupId>org.richfaces.cdk</groupId>
- <artifactId>maven-cdk-plugin</artifactId>
- <version>${org.richfaces.cdk.version}</version>
- </plugin>
- <plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.1</version>
@@ -92,21 +87,10 @@
<version>2.0-alpha-4</version>
<extensions>true</extensions>
</plugin>
- </plugins>
- </pluginManagement>
-
- <plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-enforcer-plugin</artifactId>
- <version>1.0-beta-1</version>
- <configuration>
- <fail>false</fail>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.richfaces.cdk</groupId>
<artifactId>maven-cdk-plugin</artifactId>
+ <version>${org.richfaces.cdk.version}</version>
<executions>
<execution>
<id>cdk-generate-sources</id>
@@ -117,6 +101,18 @@
</execution>
</executions>
</plugin>
+ </plugins>
+ </pluginManagement>
+
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-enforcer-plugin</artifactId>
+ <version>1.0-beta-1</version>
+ <configuration>
+ <fail>false</fail>
+ </configuration>
+ </plugin>
</plugins>
</build>
14 years, 6 months
JBoss Rich Faces SVN: r17639 - root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources.
by richfaces-svn-commits@lists.jboss.org
Author: konstantin.mishin
Date: 2010-06-18 14:16:11 -0400 (Fri, 18 Jun 2010)
New Revision: 17639
Modified:
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.ecss
root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
Log:
RF-8101
Modified: root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.ecss
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.ecss 2010-06-18 16:56:52 UTC (rev 17638)
+++ root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.ecss 2010-06-18 18:16:11 UTC (rev 17639)
@@ -148,4 +148,8 @@
width: 9px;
background-image: url("#{resource['reorderMarker.gif']}");
display: none;
+}
+
+.rf-edt-r-s {
+ background-color: '#{richSkin.additionalBackgroundColor}'; /*TODO Probably use other skin property.*/
}
\ No newline at end of file
Modified: root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js
===================================================================
--- root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-06-18 16:56:52 UTC (rev 17638)
+++ root/ui/iteration/trunk/tables/ui/src/main/resources/META-INF/resources/extendedDataTable.js 2010-06-18 18:16:11 UTC (rev 17639)
@@ -20,11 +20,13 @@
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
(function(richfaces, jQuery) {
- richfaces.getCSSRule = function (className) {
+ richfaces.utils = richfaces.utils || {};
+
+ richfaces.utils.getCSSRule = function (className) {
var rule = null;
var sheets = document.styleSheets;
for (var j = 0; !rule && j < sheets.length; j++) {
- var rules = sheets[j].cssRules ? sheets[j].cssRules: sheets[j].rules;
+ var rules = sheets[j].cssRules ? sheets[j].cssRules : sheets[j].rules;
for (var i = 0; !rule && i < rules.length; i++) {
if (rules[i].selectorText && rules[i].selectorText.toLowerCase() == className.toLowerCase()) {
rule = rules[i];
@@ -34,19 +36,127 @@
return rule;
};
+ richfaces.utils.Ranges = function() {
+ this.ranges = [];
+ };
+
+ richfaces.utils.Ranges.prototype = {
+
+ add: function(index) {
+ var i = 0;
+ while(i < this.ranges.length && index >= this.ranges[i++][1]);
+ i--;
+ if(this.ranges[i-1] && index==(this.ranges[i-1][1]+1) ) {
+ if(index==(this.ranges[i][0]-1)) {
+ this.ranges[i-1][1] = this.ranges[i][1];
+ this.ranges.splice(i, 1);
+ } else {
+ this.ranges[i-1][1]++;
+ }
+ } else {
+ if(this.ranges[i]){
+ if(this.ranges[i] && index==(this.ranges[i][0]-1)) {
+ this.ranges[i][0]--;
+ } else {
+ if(index==(this.ranges[i][1]+1)){
+ this.ranges[i][1]++;
+ } else {
+ if(index<this.ranges[i][1]){
+ this.ranges.splice(i, 0, [index, index]);
+ } else {
+ this.ranges.splice(i + 1, 0, [index, index]);
+ }
+ }
+ }
+ } else {
+ this.ranges.splice(i, 0, [index, index]);
+ }
+ }
+ },
+
+ remove: function(index) {
+ var i = 0;
+ while(i < this.ranges.length && index > this.ranges[i++][1]);
+ i--;
+ if(this.ranges[i]) {
+ if(index==(this.ranges[i][1]) ) {
+ if(index==(this.ranges[i][0])){
+ this.ranges.splice(i, 1);
+ } else {
+ this.ranges[i][1]--;
+ }
+ } else {
+ if(index==(this.ranges[i][0])){
+ this.ranges[i][0]++;
+ } else {
+ this.ranges.splice(i+1, 0, [index+1, this.ranges[i][1]]);
+ this.ranges[i][1] = index-1;
+ }
+ }
+ }
+ },
+
+ remove: function(index) {
+ var i = 0;
+ while(i < this.ranges.length && index > this.ranges[i++][1]);
+ i--;
+ if(this.ranges[i]) {
+ if(index==(this.ranges[i][1]) ) {
+ if(index==(this.ranges[i][0])){
+ this.ranges.splice(i, 1);
+ } else {
+ this.ranges[i][1]--;
+ }
+ } else {
+ if(index==(this.ranges[i][0])){
+ this.ranges[i][0]++;
+ } else {
+ this.ranges.splice(i+1, 0, [index+1, this.ranges[i][1]]);
+ this.ranges[i][1] = index-1;
+ }
+ }
+ }
+ },
+
+ clear: function() {
+ this.ranges = [];
+ },
+
+ isSelected: function(index) {
+ var i = 0;
+ while(i < this.ranges.length && index >= this.ranges[i][0]) {
+ if(index >= this.ranges[i][0] && index <= this.ranges[i][1]) {
+ return true;
+ } else {
+ i++;
+ }
+ }
+ return false;
+ },
+
+ toString: function() {
+ var ret = new Array(this.ranges.length);
+ for (var i = 0; i < this.ranges.length; i++) {
+ ret[i] = this.ranges[i].join();
+ }
+ return ret.join(";");
+ }
+ };
+
richfaces.ExtendedDataTable = function(id, rowCount, ajaxFunction, ajaxParameters) {
var WIDTH_CLASS_NAME_BASE = "rf-edt-cw-";
var MIN_WIDTH = 20;
+ var ranges = new richfaces.utils.Ranges();
var element = document.getElementById(id);
- var bodyElement, contentElement, spacerElement, dataTableElement, rows, rowHeight, parts;
+ var bodyElement, contentElement, spacerElement, dataTableElement, rows, rowHeight, parts, tbodies, shiftIndex, activeIndex;
var dragElement = document.getElementById(id + ":d");
var reorderElement = document.getElementById(id + ":r");
var reorderMarkerElement = document.getElementById(id + ":rm");
var widthInput = document.getElementById(id + ":wi");
- var normalPartStyle = richfaces.getCSSRule(".rf-edt-pw").style;
+ var normalPartStyle = richfaces.utils.getCSSRule(".rf-edt-pw").style;
var header = jQuery(element).children(".rf-edt-h");
- var resizerHolders = header.find(".rf-edt-rsh").get();
+ var resizerHolders = header.find(".rf-edt-rsh");
var frozenHeaderPartElement = document.getElementById(id + ":frozenHeader");
var frozenColumnCount = frozenHeaderPartElement ? frozenHeaderPartElement.firstChild.rows[0].cells.length : 0;//TODO Richfaces.firstDescendant;
@@ -103,7 +213,7 @@
};
var adjustResizers = function() {
- var scrollLeft = scrollElement.scrollLeft;
+ var scrollLeft = scrollElement ? scrollElement.scrollLeft : 0;
var clientWidth = element.clientWidth - 3;
var i = 0;
for (; i < frozenColumnCount; i++) {
@@ -140,25 +250,29 @@
};
var updateScrollPosition = function() {
- var scrollLeft = scrollElement.scrollLeft;
- parts.each(function() {
- this.scrollLeft = scrollLeft;
- });
+ if (scrollElement) {
+ var scrollLeft = scrollElement.scrollLeft;
+ parts.each(function() {
+ this.scrollLeft = scrollLeft;
+ });
+ }
adjustResizers();
};
var initializeLayout = function() {
bodyElement = document.getElementById(id + ":b");
- contentElement = jQuery(bodyElement).children("div:first").get(0);
+ contentElement = jQuery(bodyElement).children("div:first")[0];
if (contentElement) {
spacerElement = contentElement.firstChild;//TODO this.marginElement = Richfaces.firstDescendant(this.contentElement);
dataTableElement = contentElement.lastChild;//TODO this.dataTableElement = Richfaces.lastDescendant(this.contentElement);
- rows = document.getElementById(id + ":body").firstChild.rows.length;//TODO Richfaces.firstDescendant;
+ tbodies = jQuery(document.getElementById(id + ":tbf")).add(document.getElementById(id + ":tbn"));
+ rows = tbodies[0].rows.length;
rowHeight = dataTableElement.offsetHeight / rows;
if (rowCount != rows) {
contentElement.style.height = (rowCount * rowHeight) + "px";
}
- jQuery(bodyElement).bind("scroll", bodyScrollListener);
+ jQuery(bodyElement).bind("scroll", bodyScrollListener)
+ tbodies.bind("click", selectionClickListener);
} else {
spacerElement = null;
dataTableElement = null;
@@ -189,7 +303,7 @@
var setColumnWidth = function(id, width) {
width = width + "px";
- richfaces.getCSSRule("." + WIDTH_CLASS_NAME_BASE + id).style.width = width;
+ richfaces.utils.getCSSRule("." + WIDTH_CLASS_NAME_BASE + id).style.width = width;
newWidths[id] = width;
var widthsArray = new Array();
for (var id in newWidths) {
@@ -280,6 +394,83 @@
}
};
+ var selectRow = function (index) {
+ ranges.add(index);
+ for ( var i = 0; i < tbodies.length; i++) {
+ tbodies[i].rows[index].className = "rf-edt-r-s";
+ }
+ }
+
+ var deselectRow = function (index, skipUpdateModel) {
+ if (!skipUpdateModel) {
+ ranges.remove(index);
+ }
+ for ( var i = 0; i < tbodies.length; i++) {
+ tbodies[i].rows[index].className = "";
+ }
+ }
+
+ var selectionClickListener = function (event) {
+ var tr = event.target;
+ while (tbodies.index(tr.parentNode) == -1) {
+ tr = tr.parentNode;
+ }
+ var index = tr.rowIndex;
+
+ if(!event.shiftKey) {
+ shiftIndex = null;
+ } else {
+ if (window.getSelection) {
+ window.getSelection().removeAllRanges(); //TODO
+ } else if (document.selection) {
+ document.selection.empty();
+ }
+ }
+ if (event.shiftKey && !event.ctrlKey) {
+ if(!shiftIndex) {//TODO
+ shiftIndex = activeIndex;
+ }
+ var range;
+ if (index >= shiftIndex) {
+ range = [shiftIndex, index];
+ } else {
+ range = [index, shiftIndex];
+ }
+ var i = 0;
+ for (; i < range[0]; i++) {
+ if (ranges.isSelected(i)) {
+ deselectRow(i);
+ }
+ }
+ for (; i <= range[1]; i++) {
+ if (!ranges.isSelected(i)) {
+ selectRow(i);
+ }
+ }
+ for (; i < rows; i++) {
+ if (ranges.isSelected(i)) {
+ deselectRow(i);
+ }
+ }
+ } else if (!event.shiftKey && event.ctrlKey) {
+ if (ranges.isSelected(index)) {
+ deselectRow(index);
+ } else {
+ selectRow(index);
+ }
+ } else if (!event.shiftKey && !event.ctrlKey) {
+ ranges.clear();
+ for (var i = 0; i < rows; i++) {
+ if (i == index) {
+ selectRow(i);
+ } else {
+ deselectRow(i, true);
+ }
+ }
+ }
+ activeIndex = index;
+ }
+
var ajaxComplete = function (event, data) {
if (data.reinitializeHeader) {
bindHeaderHandlers();
@@ -302,7 +493,6 @@
header.find(".rf-edt-hc").bind("mousedown", beginReorder);
}
bindHeaderHandlers();
- jQuery(bodyElement).bind("scroll", bodyScrollListener);
jQuery(element).bind("rich:onajaxcomplete", ajaxComplete);
//JS API
@@ -313,7 +503,7 @@
var position;
var headers = header.find(".rf-edt-hc");
for (var i = 0; i < headers.length; i++) {
- if (id == headers.get(i).className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
+ if (id == headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1]) {
position = i;
}
}
@@ -325,7 +515,7 @@
var before;
var headers = header.find(".rf-edt-hc");
for (var i = 0; i < headers.length; i++) {
- var current = headers.get(i).className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
+ var current = headers[i].className.match(new RegExp(WIDTH_CLASS_NAME_BASE + "([^\\W]*)"))[1];
if (i == position) {
if (before) {
colunmsOrder += current + "," + id + ",";
14 years, 6 months
JBoss Rich Faces SVN: r17638 - in root/core/branches/jsr-330: impl/src/main/resources/META-INF/resources and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-18 12:56:52 -0400 (Fri, 18 Jun 2010)
New Revision: 17638
Modified:
root/core/branches/jsr-330/
root/core/branches/jsr-330/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
Log:
Merged revisions 17635 via svnmerge from
https://svn.jboss.org/repos/richfaces/root/core/trunk
.......
r17635 | pyaschenko | 2010-06-17 03:59:10 -0700 (Thu, 17 Jun 2010) | 1 line
autocomplete prototype
.......
Property changes on: root/core/branches/jsr-330
___________________________________________________________________
Name: svnmerge-integrated
- /root/core/trunk:1-17624
+ /root/core/trunk:1-17637
Modified: root/core/branches/jsr-330/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
--- root/core/branches/jsr-330/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-06-18 12:42:03 UTC (rev 17637)
+++ root/core/branches/jsr-330/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-06-18 16:56:52 UTC (rev 17638)
@@ -151,7 +151,6 @@
* @name RichFaces.BaseComponent#destroy
*
* */
- // TODO: add to article
destroy: function() {
}
};
14 years, 6 months
JBoss Rich Faces SVN: r17637 - root/ui-sandbox/panels/trunk/docs.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-06-18 08:42:03 -0400 (Fri, 18 Jun 2010)
New Revision: 17637
Added:
root/ui-sandbox/panels/trunk/docs/client_side_api 1.2.2.png
root/ui-sandbox/panels/trunk/docs/client_side_api-dev 1.2.2.png
root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.2.png
root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.2.png
Removed:
root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.png
Log:
RF-8745 TogglePanel component
client side api
Added: root/ui-sandbox/panels/trunk/docs/client_side_api 1.2.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/client_side_api 1.2.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/panels/trunk/docs/client_side_api-dev 1.2.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/client_side_api-dev 1.2.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Deleted: root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.png
===================================================================
(Binary files differ)
14 years, 6 months
JBoss Rich Faces SVN: r17636 - in root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script: images and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-06-17 11:23:38 -0400 (Thu, 17 Jun 2010)
New Revision: 17636
Added:
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_btn.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_press.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn1.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_field.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press1.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_shadow.png
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down.gif
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down1.gif
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/spacer.gif
Modified:
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js
Log:
autocomplete prototype
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js 2010-06-17 10:59:10 UTC (rev 17635)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js 2010-06-17 15:23:38 UTC (rev 17636)
@@ -60,7 +60,8 @@
var bindEventHandlers = function() {
if (this.options.buttonId) {
- rf.Event.bindById(this.options.buttonId, "click"+this.namespace, onButtonShow, this);
+ rf.Event.bindById(this.options.buttonId, "mousedown"+this.namespace, onButtonShow, this);
+ rf.Event.bindById(this.options.buttonId, "mouseup"+this.namespace, onSelectMouseUp, this);
}
var inputEventHandlers = {};
@@ -81,15 +82,17 @@
};
var onSelectMouseDown = function () {
this.isMouseDown = true;
- console.log("onMouseDown");
+ console && console.log && console.log("onMouseDown");
};
var onSelectMouseUp = function () {
- this.isMouseDown = false;
- console.log("onMouseUp");
+ //this.isMouseDown = false;
+ rf.getDomElement(this.fieldId).focus();
+ console && console.log && console.log("onMouseUp");
};
var onButtonShow = function (event) {
- console.log("onButtonShow - "+this.timeoutId);
+ this.isMouseDown = true;
+ console && console.log && console.log("onButtonShow - "+this.timeoutId);
if (this.timeoutId) {
window.clearTimeout(this.timeoutId);
this.timeoutId = null;
@@ -100,19 +103,21 @@
this.hide(event);
} else {
this.show(event);
- rf.getDomElement(this.fieldId).focus();
+ //rf.getDomElement(this.fieldId).focus();
}
};
var onFocus = function (event) {
+ console && console.log && console.log("onFocus");
};
var onBlur = function (event) {
- console.log("onBlur");
+ console && console.log && console.log("onBlur");
if (this.isMouseDown) {
rf.getDomElement(this.fieldId).focus();
- console.log("onBlur and focus");
- } else if (this.isVisible/*&& checkOnBlur.call(this, event)*/) {
+ this.isMouseDown = false;
+ console && console.log && console.log("---------> and focus");
+ } else if (this.isVisible && !this.isMouseDown/*&& checkOnBlur.call(this, event)*/) {
var _this = this;
this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
}
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_btn.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_btn.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_press.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/Copy of bg_press.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn1.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_btn1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_field.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_field.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press1.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_press1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_shadow.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/bg_shadow.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down.gif
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down1.gif
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/down1.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/spacer.gif
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/images/spacer.gif
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 6 months
JBoss Rich Faces SVN: r17635 - in root: ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script and 1 other directory.
by richfaces-svn-commits@lists.jboss.org
Author: pyaschenko
Date: 2010-06-17 06:59:10 -0400 (Thu, 17 Jun 2010)
New Revision: 17635
Modified:
root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html
root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js
Log:
autocomplete prototype
Modified: root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js
===================================================================
--- root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-06-17 10:39:26 UTC (rev 17634)
+++ root/core/trunk/impl/src/main/resources/META-INF/resources/richfaces-base-component.js 2010-06-17 10:59:10 UTC (rev 17635)
@@ -151,7 +151,6 @@
* @name RichFaces.BaseComponent#destroy
*
* */
- // TODO: add to article
destroy: function() {
}
};
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html 2010-06-17 10:39:26 UTC (rev 17634)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/1.html 2010-06-17 10:59:10 UTC (rev 17635)
@@ -39,9 +39,10 @@
</head>
<body style="margin : 30px">
+<form>
+<div style="height:300px; width:300px; overflow:auto;">
+Text block text block text block text block text block text block text block text block
-
-Text block text block text block text block text block text block text block text block
<div id="myCombo" class=" cb_field_width cb_field">
<div style=" position : relative; overflow : hidden; text-align : left; padding-right : 21px;">
<input id="myComboInput" type="Text" class="cb_font cb_input">
@@ -73,7 +74,9 @@
</script>
</div>
text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block
+text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block text block
+</div>
+</form>
-
</body>
</html>
Modified: root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js
===================================================================
--- root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js 2010-06-17 10:39:26 UTC (rev 17634)
+++ root/ui-sandbox/inputs/trunk/autocomplete/src/main/resources/META-INF/resources/script/autocomplete.js 2010-06-17 10:59:10 UTC (rev 17635)
@@ -1,3 +1,25 @@
+// TODO: move this extend to RichFaces.Event for exapmle
+$.extend(RichFaces.Event, {
+ bindScrollEventHandlers: function(element, handler, component) {
+ var elements = [];
+ element = RichFaces.getDomElement(element).parentNode;
+ while (element && element!=window.document.body)
+ {
+ if (element.offsetWidth!=element.scrollWidth || element.offsetHeight!=element.scrollHeight)
+ {
+ elements.push(element);
+ RichFaces.Event.bind(element, "scroll"+component.getNamespace(), handler, component);
+ }
+ element = element.parentNode;
+ }
+ return elements;
+ },
+ unbindScrollEventHandlers: function(elements, component) {
+ RichFaces.Event.unbind(elements, component.getNamespace());
+ elements = null;
+ }
+});
+
(function ($, rf) {
rf.ui = rf.ui || {};
@@ -9,8 +31,7 @@
this.componentId = componentId;
this.fieldId = fieldId;
this.options = $.extend({}, defaultOptions, options);
- this.hasFocus = 0;
- this.namespace = rf.Event.createNamespace(this.name, this.componentId);
+ this.namespace = "."+rf.Event.createNamespace(this.name, this.componentId);
bindEventHandlers.call(this);
};
@@ -26,34 +47,151 @@
};
var KEYS = {
+ BACKSPACE: 8,
+ TAB: 9,
+ RETURN: 13,
+ ESC: 27,
+ PAGEUP: 33,
+ PAGEDOWN: 34,
+ UP: 38,
+ DOWN: 40,
+ DEL: 46
};
var bindEventHandlers = function() {
if (this.options.buttonId) {
- rf.Event.bindById(this.options.buttonId, "click."+this.namespace, onButtonShow, this);
- var inputEventHandlers = {};
- inputEventHandlers["focus."+this.namespace] = onFocus;
- rf.Event.bindById(this.fieldId, inputEventHandlers, this);
+ rf.Event.bindById(this.options.buttonId, "click"+this.namespace, onButtonShow, this);
}
+
+ var inputEventHandlers = {};
+ inputEventHandlers["focus"+this.namespace] = onFocus;
+ inputEventHandlers["blur"+this.namespace] = onBlur;
+ inputEventHandlers["click"+this.namespace] = onClick;
+ inputEventHandlers[($.browser.opera ? "keypress" : "keydown")+this.namespace] = onKeyDown;
+ rf.Event.bindById(this.fieldId, inputEventHandlers, this);
+
+ inputEventHandlers = {};
+ inputEventHandlers["click"+this.namespace] = onSelectClick;
+ inputEventHandlers["mousedown"+this.namespace] = onSelectMouseDown;
+ inputEventHandlers["mouseup"+this.namespace] = onSelectMouseUp;
+ rf.Event.bindById(this.componentId, inputEventHandlers, this);
}
+ var onSelectClick = function () {
+ };
+ var onSelectMouseDown = function () {
+ this.isMouseDown = true;
+ console.log("onMouseDown");
+ };
+ var onSelectMouseUp = function () {
+ this.isMouseDown = false;
+ console.log("onMouseUp");
+ };
+
var onButtonShow = function (event) {
+ console.log("onButtonShow - "+this.timeoutId);
+ if (this.timeoutId) {
+ window.clearTimeout(this.timeoutId);
+ this.timeoutId = null;
+ rf.getDomElement(this.fieldId).focus();
+ }
+
if (this.isVisible) {
this.hide(event);
} else {
this.show(event);
+ rf.getDomElement(this.fieldId).focus();
}
- }
+ };
- var onHide = function (event) {
- $(rf.getDomElement(this.componentId)).hide();
- this.isVisible = false;
+ var onFocus = function (event) {
+ };
+
+ var onBlur = function (event) {
+ console.log("onBlur");
+ if (this.isMouseDown) {
+ rf.getDomElement(this.fieldId).focus();
+ console.log("onBlur and focus");
+ } else if (this.isVisible/*&& checkOnBlur.call(this, event)*/) {
+ var _this = this;
+ this.timeoutId = window.setTimeout(function(){_this.hide();}, 200);
+ }
+ };
+
+ var onClick = function (event) {
+ };
+
+ var onChange = function () {
+ if (!this.isVisible) {
+ this.show();
+ }
}
- var onFocus = function (event) {
- alert("aaa");
- this.destroy();
- this.hasFocus ++;
+ /*var checkOnBlur = function (event) {
+ var e = $(rf.getDomElement(this.options.buttonId));
+ return (e == event.target) || $(event.target).closest(e);
+ };*/
+
+ var selectPrevItem = function () {
+ };
+ var selectNextItem = function () {
+ };
+ var selectPageUp = function () {
+ };
+ var selectPageDown = function () {
+ };
+
+ var onKeyDown = function (event) {
+ switch(event.which) {
+ case KEYS.UP:
+ event.preventDefault();
+ if (this.isVisible) {
+ selectPrevItem();
+ }
+ break;
+ case KEYS.DOWN:
+ event.preventDefault();
+ if (this.isVisible) {
+ selectNextItem();
+ }
+ break;
+ case KEYS.PAGEUP:
+ event.preventDefault();
+ if (this.isVisible) {
+ selectPageUp();
+ }
+ break;
+ case KEYS.PAGEDOWN:
+ event.preventDefault();
+ if (this.isVisible) {
+ selectPageDown();
+ }
+ break;
+ case KEYS.TAB:
+ case KEYS.RETURN:
+ event.preventDefault();
+ /*if( selectCurrent() ) {
+ event.preventDefault();
+ //TODO: bind form submit event handler to cancel form submit under the opera
+ cancelSubmit = true;
+ return false;
+ }*/
+ this.hide();
+ break;
+ case KEYS.ESC:
+ this.hide();
+ break;
+ default:
+ if (!this.options.selectOnly) {
+ if (this.options.changeDelay) {
+ var _this = this;
+ this.changeTimerId = window.setTimeout(function(){onChange.call(_this);}, this.options.changeDelay)
+ } else {
+ onChange.call(this);
+ }
+ }
+ break;
+ }
}
// Add new properties and methods
@@ -63,12 +201,20 @@
show: function (event) {
$(rf.getDomElement(this.componentId)).show();
this.isVisible = true;
+ this.scrollElements = rf.Event.bindScrollEventHandlers(this.componentId, this.hide, this);
},
- hide: onHide,
+ hide: function (event) {
+ rf.Event.unbindScrollEventHandlers(this.scrollElements, this);
+ $(rf.getDomElement(this.componentId)).hide();
+ this.isVisible = false;
+ },
destroy: function () {
- rf.Event.unbindById(this.options.buttonId, "."+this.namespace);
- rf.Event.unbindById(this.fieldId, "."+this.namespace);
+ rf.Event.unbindById(this.options.buttonId, this.namespace);
+ rf.Event.unbindById(this.fieldId, this.namespace);
$super.destroy.call(this);
+ },
+ getNamespace: function () {
+ return this.namespace;
}
};
})());
14 years, 6 months
JBoss Rich Faces SVN: r17634 - root/ui-sandbox/panels/trunk/docs.
by richfaces-svn-commits@lists.jboss.org
Author: Alex.Kolonitsky
Date: 2010-06-17 06:39:26 -0400 (Thu, 17 Jun 2010)
New Revision: 17634
Added:
root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.1.png
root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.png
root/ui-sandbox/panels/trunk/docs/taglib-toggle 1.2.png
Log:
RFPL-602 Update component module archetypes
taglib definitions for panels
Added: root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.1.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/panels-taglib 1.2.1.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/taglib-dev 1.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: root/ui-sandbox/panels/trunk/docs/taglib-toggle 1.2.png
===================================================================
(Binary files differ)
Property changes on: root/ui-sandbox/panels/trunk/docs/taglib-toggle 1.2.png
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
14 years, 6 months
JBoss Rich Faces SVN: r17633 - in root/core/branches/jsr-330: impl/src/main/java/org/richfaces/application and 2 other directories.
by richfaces-svn-commits@lists.jboss.org
Author: alexsmirnov
Date: 2010-06-16 20:29:54 -0400 (Wed, 16 Jun 2010)
New Revision: 17633
Modified:
root/core/branches/jsr-330/impl/pom.xml
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java
root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
Log:
fix tests
Modified: root/core/branches/jsr-330/impl/pom.xml
===================================================================
--- root/core/branches/jsr-330/impl/pom.xml 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/pom.xml 2010-06-17 00:29:54 UTC (rev 17633)
@@ -47,7 +47,6 @@
<dependency>
<groupId>org.richfaces.core</groupId>
<artifactId>jsr330-impl</artifactId>
- <version>${project.version}</version>
</dependency>
<dependency>
<groupId>net.sourceforge.cssparser</groupId>
Modified: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/DefaultModule.java 2010-06-17 00:29:54 UTC (rev 17633)
@@ -2,19 +2,19 @@
import org.ajax4jsf.cache.Cache;
import org.ajax4jsf.renderkit.AJAXDataSerializer;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.resource.DefaultResourceCodec;
import org.richfaces.resource.ResourceCodec;
import org.richfaces.skin.SkinFactory;
import org.richfaces.skin.SkinFactoryImpl;
-public class DefaultModule implements BindingModule {
+public class DefaultModule implements Module {
public void configure(InjectorConfig injector) {
- injector.register(SkinFactory.class).to(SkinFactoryImpl.class);
- injector.register(AJAXDataSerializer.class).to(AJAXDataSerializer.class);
- injector.register(ResourceCodec.class).toService(DefaultResourceCodec.class);
+ injector.register(SkinFactory.class).to(SkinFactoryImpl.class).asSingleton();
+ injector.register(AJAXDataSerializer.class).to(AJAXDataSerializer.class).asSingleton();
+ injector.register(ResourceCodec.class).toService(DefaultResourceCodec.class).asSingleton();
injector.register(Cache.class).toProviderInstance(new CacheProvider());
}
Modified: root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java
===================================================================
--- root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/src/main/java/org/richfaces/application/InitializationListener.java 2010-06-17 00:29:54 UTC (rev 17633)
@@ -31,7 +31,7 @@
import javax.faces.event.SystemEvent;
import javax.faces.event.SystemEventListener;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.DependencyException;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.jsr330.ServiceException;
@@ -58,11 +58,11 @@
protected DependencyInjector createInjector() {
InjectorImpl injector = new InjectorImpl();
- ArrayList<BindingModule> modules = new ArrayList<BindingModule>();
+ ArrayList<Module> modules = new ArrayList<Module>();
modules.add(new DefaultModule());
try {
- modules.addAll(ServiceLoader.loadServices(BindingModule.class));
- injector.init(modules.toArray(new BindingModule[]{}));
+ modules.addAll(ServiceLoader.loadServices(Module.class));
+ injector.init(modules.toArray(new Module[]{}));
} catch (ServiceException e) {
throw new FacesException(e);
} catch (DependencyException e) {
Modified: root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java
===================================================================
--- root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/AbstractBaseResourceTest.java 2010-06-17 00:29:54 UTC (rev 17633)
@@ -41,7 +41,7 @@
import org.easymock.EasyMock;
import org.jboss.test.faces.AbstractFacesTest;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.util.Util;
@@ -143,7 +143,7 @@
EasyMock.eq(null), EasyMock.eq("4_0_alpha"))).andReturn("/rfRes/Resource2/4_0_alpha");
EasyMock.replay(resourceCodec);
InjectorImpl injector = new InjectorImpl();
- injector.init(new BindingModule(){
+ injector.init(new Module(){
public void configure(InjectorConfig injector) {
injector.register(ResourceCodec.class).toInstance(resourceCodec);
Modified: root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java
===================================================================
--- root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/impl/src/test/java/org/richfaces/resource/ResourceHandlerImplTest.java 2010-06-17 00:29:54 UTC (rev 17633)
@@ -41,7 +41,7 @@
import org.jboss.test.faces.AbstractFacesTest;
import org.jboss.test.faces.htmlunit.LocalWebClient;
import org.richfaces.application.ServiceTracker;
-import org.richfaces.jsr330.BindingModule;
+import org.richfaces.jsr330.Module;
import org.richfaces.jsr330.InjectorConfig;
import org.richfaces.jsr330.InjectorImpl;
import org.richfaces.util.Util;
@@ -223,6 +223,7 @@
setupFacesRequest();
final ResourceCodec mockedCodec = EasyMock.createNiceMock(ResourceCodec.class);
+ final org.ajax4jsf.cache.Cache mockCache = EasyMock.createNiceMock(org.ajax4jsf.cache.Cache.class);
EasyMock.expect(mockedCodec.decodeResourceName(EasyMock.<FacesContext>notNull(),
EasyMock.eq("StateHolderResource"))).andReturn("org.richfaces.resource.StateHolderResourceImpl");
@@ -232,12 +233,13 @@
EasyMock.eq("StateHolderResource"))).andReturn(null);
EasyMock.expect(mockedCodec.getResourceKey(EasyMock.<FacesContext>notNull(),
EasyMock.eq("StateHolderResource"))).andReturn("StateHolderResource.jsf?db=1");
- EasyMock.replay(mockedCodec);
+ EasyMock.replay(mockedCodec,mockCache);
InjectorImpl injector = new InjectorImpl();
- injector.init(new BindingModule(){
+ injector.init(new Module(){
public void configure(InjectorConfig injector) {
injector.register(ResourceCodec.class).toInstance(mockedCodec);
+ injector.register(org.ajax4jsf.cache.Cache.class).toInstance(mockCache);
}
});
Modified: root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java
===================================================================
--- root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-17 00:23:45 UTC (rev 17632)
+++ root/core/branches/jsr-330/jsr330-impl/src/main/java/org/richfaces/jsr330/BinderImpl.java 2010-06-17 00:29:54 UTC (rev 17633)
@@ -48,7 +48,7 @@
private final Scope<T> singltonScope = new Scope<T>() {
- private boolean instantiated = false;
+ private volatile boolean instantiated = false;
private volatile T value;
@@ -72,13 +72,14 @@
FacesContext facesContext = FacesContext.getCurrentInstance();
if (null != facesContext) {
Map<String, Object> map = getMap(facesContext);
- value = (T) map.get(target.toString());
+ String key = target.toString();
+ value = (T) map.get(key);
if(null == value){
rwLock.readLock().unlock();
rwLock.writeLock().lock();
try {
value = getProvider().get();
- map.put(target.toString(), value);
+ map.put(key, value);
} finally {
rwLock.readLock().lock();
rwLock.writeLock().unlock();
14 years, 6 months