You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by mg...@apache.org on 2013/06/28 10:53:51 UTC

[4/9] git commit: Added return CdiConfiguration new config calls

Added return CdiConfiguration new config calls

Formatted File and added return CdiConfiguration to match rest of
configuration setters.


Project: http://git-wip-us.apache.org/repos/asf/wicket/repo
Commit: http://git-wip-us.apache.org/repos/asf/wicket/commit/265934a9
Tree: http://git-wip-us.apache.org/repos/asf/wicket/tree/265934a9
Diff: http://git-wip-us.apache.org/repos/asf/wicket/diff/265934a9

Branch: refs/heads/5257-css-settings
Commit: 265934a9870b686d76b44a483a00836abbc6cdc4
Parents: 434a708
Author: John Sarman <jo...@gmail.com>
Authored: Thu Jun 27 16:07:08 2013 -0400
Committer: John Sarman <jo...@gmail.com>
Committed: Thu Jun 27 16:07:08 2013 -0400

----------------------------------------------------------------------
 .../org/apache/wicket/cdi/CdiConfiguration.java | 78 +++++++++++---------
 1 file changed, 44 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/wicket/blob/265934a9/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
----------------------------------------------------------------------
diff --git a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
index 3f82585..a7175f0 100644
--- a/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
+++ b/wicket-experimental/wicket-cdi-1.1/wicket-cdi-1.1-core/src/main/java/org/apache/wicket/cdi/CdiConfiguration.java
@@ -20,6 +20,7 @@ import java.util.Arrays;
 import java.util.Iterator;
 import java.util.Set;
 import java.util.TreeSet;
+
 import javax.annotation.PostConstruct;
 import javax.enterprise.context.ApplicationScoped;
 import javax.enterprise.context.spi.CreationalContext;
@@ -35,25 +36,24 @@ import org.apache.wicket.request.cycle.RequestCycleListenerCollection;
 
 /**
  * Configures CDI integration
- * 
+ *
  * @author igor
- * 
  */
 @ApplicationScoped
 public class CdiConfiguration
 {
 	private static final String[] defaultIgnoredPackages = new String[]
-	{
-		"org.apache.wicket.markup",       
-		"org.apache.wicket.protocol.http",
-		"org.apache.wicket.behavior",
-	};
-    
+			{
+					"org.apache.wicket.markup",
+					"org.apache.wicket.protocol.http",
+					"org.apache.wicket.behavior",
+			};
+
 	private IConversationPropagation propagation = ConversationPropagation.NONBOOKMARKABLE;
 
 	@Inject
 	BeanManager beanManager;
-        
+
 	@Inject
 	INonContextualManager nonContextualManager;
 
@@ -65,7 +65,7 @@ public class CdiConfiguration
 
 	@Inject
 	Instance<DetachEventEmitter> detachEventEmitterSource;
-        
+
 	@Inject
 	BehaviorInjector behaviorInjector;
 
@@ -74,7 +74,7 @@ public class CdiConfiguration
 
 	@Inject
 	SessionInjector sessionInjector;
-	
+
 	private boolean injectComponents = true;
 	private boolean injectApplication = true;
 	private boolean injectSession = true;
@@ -89,10 +89,10 @@ public class CdiConfiguration
 		ignoredPackages = new TreeSet<>();
 		ignoredPackages.addAll(Arrays.asList(defaultIgnoredPackages));
 	}
-        
+
 	/**
 	 * Gets the configured bean manager
-	 * 
+	 *
 	 * @return bean manager or {@code null} if none
 	 */
 	public BeanManager getBeanManager()
@@ -100,7 +100,10 @@ public class CdiConfiguration
 		return beanManager;
 	}
 
-	public @Produces @Propagation IConversationPropagation getPropagation()
+	public
+	@Produces
+	@Propagation
+	IConversationPropagation getPropagation()
 	{
 		return propagation;
 	}
@@ -109,26 +112,28 @@ public class CdiConfiguration
 	 * Checks if auto conversation management is enabled. See
 	 * {@link #setAutoConversationManagement(boolean)} for details.
 	 */
-	public @Produces @Auto Boolean isAutoConversationManagement()
+	public
+	@Produces
+	@Auto
+	Boolean isAutoConversationManagement()
 	{
 		return autoConversationManagement;
 	}
 
 	/**
 	 * Toggles automatic conversation management feature.
-	 * 
+	 * <p/>
 	 * Automatic conversation management controls the lifecycle of the conversation based on
 	 * presence of components implementing the {@link ConversationalComponent} interface. If such
 	 * components are found in the page a conversation is marked persistent, and if they are not the
 	 * conversation is marked transient. This greatly simplifies the management of conversation
 	 * lifecycle.
-	 * 
+	 * <p/>
 	 * Sometimes it is necessary to manually control the application. For these cases, once a
 	 * conversation is started {@link AutoConversation} bean can be used to mark the conversation as
 	 * manually-managed.
-	 * 
+	 *
 	 * @param enabled
-	 * 
 	 * @return {@code this} for easy chaining
 	 */
 	public CdiConfiguration setAutoConversationManagement(boolean enabled)
@@ -148,7 +153,7 @@ public class CdiConfiguration
 		return nonContextualManager;
 	}
 
-	
+
 	public boolean isInjectComponents()
 	{
 		return injectComponents;
@@ -193,44 +198,49 @@ public class CdiConfiguration
 		return this;
 	}
 
-	public @Produces @IgnoreList String[] getPackagesToIgnore()
+	public
+	@Produces
+	@IgnoreList
+	String[] getPackagesToIgnore()
 	{
 		String[] ignore = new String[ignoredPackages.size()];
 		return ignoredPackages.toArray(ignore);
 	}
 
-	public void addPackagesToIgnore(String ... packageNames )
+	public CdiConfiguration addPackagesToIgnore(String... packageNames)
 	{
 		ignoredPackages.addAll(Arrays.asList(packageNames));
+		return this;
 	}
 
-	public void removePackagesToIgnore(String ... packageNames)
+	public CdiConfiguration removePackagesToIgnore(String... packageNames)
 	{
 		ignoredPackages.removeAll(Arrays.asList(packageNames));
+		return this;
 	}
 
 	/**
 	 * Configures the specified application
-	 * 
+	 *
 	 * @param application
 	 * @return
 	 */
 	public synchronized void configure(Application application)
-	{		
-		if(configured)
+	{
+		if (configured)
 		{
 			throw new IllegalStateException("Cannot configure CdiConfiguration multiple times");
 		}
-		
+
 		RequestCycleListenerCollection listeners = new RequestCycleListenerCollection();
 		application.getRequestCycleListeners().add(listeners);
 
 		// enable conversation propagation
 		if (getPropagation() != ConversationPropagation.NONE)
-		{                    
+		{
 			listeners.add(conversationPropagatorSource.get());
 			application.getComponentPreOnBeforeRenderListeners().add(
-				conversationExpiryCheckerSource.get());
+					conversationExpiryCheckerSource.get());
 		}
 
 		// enable detach event
@@ -263,23 +273,23 @@ public class CdiConfiguration
 		// enable cleanup
 
 		application.getApplicationListeners().add(
-			new CdiShutdownCleaner(isInjectApplication()));
+				new CdiShutdownCleaner(isInjectApplication()));
 
 		configured = true;
 
 	}
-        
+
 	public static CdiConfiguration get()
 	{
-		BeanManager beanManager = CDI.current().getBeanManager();            
-		Iterator<Bean< ? >> iter = beanManager.getBeans(CdiConfiguration.class).iterator();
+		BeanManager beanManager = CDI.current().getBeanManager();
+		Iterator<Bean<?>> iter = beanManager.getBeans(CdiConfiguration.class).iterator();
 		if (!iter.hasNext())
 		{
 			throw new IllegalStateException("CDI BeanManager cannot find CdiConfiguration");
 		}
 		Bean<CdiConfiguration> bean = (Bean<CdiConfiguration>) iter.next();
 		CreationalContext<CdiConfiguration> ctx = beanManager.createCreationalContext(bean);
-		return (CdiConfiguration) beanManager.getReference(bean, CdiConfiguration.class, ctx);           
+		return (CdiConfiguration) beanManager.getReference(bean, CdiConfiguration.class, ctx);
 	}
 
 }