You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lu...@apache.org on 2016/12/22 01:35:13 UTC
svn commit: r1775568 [1/2] - in /myfaces/core/branches/2.3.x:
api/src/main/java/javax/faces/annotation/
api/src/main/java/javax/faces/component/
impl/src/main/java/org/apache/myfaces/cdi/component/
impl/src/main/java/org/apache/myfaces/cdi/faces/ impl/...
Author: lu4242
Date: Thu Dec 22 01:35:13 2016
New Revision: 1775568
URL: http://svn.apache.org/viewvc?rev=1775568&view=rev
Log:
MYFACES-4079 Implement CDI changes for JSF 2.3 (initial proposed solution)
Added:
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ApplicationMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/FlowMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderValuesMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/InitParameterMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestCookieMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterValuesMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/SessionMap.java
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ViewMap.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ComponentBindingExtension.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/DynamicUIComponentProxyProducer.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponent.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponentInfo.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/ApplicationScopeObjectProducer.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeBeanHolder.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeContextExtension.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeObjectProducer.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeProvider.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScoped.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopedContextImpl.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/ViewTransientScopeBeanHolder.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/ViewTransientScopeContextExtension.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/ViewTransientScopeObjectProducer.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/ViewTransientScoped.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/viewTransient/ViewTransientScopedContextImpl.java
- copied, changed from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java
Modified:
myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIComponent.java
myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/context/servlet/FacesContextImpl.java
myfaces/core/branches/2.3.x/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ApplicationMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ApplicationMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ApplicationMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ApplicationMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface ApplicationMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/FlowMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/FlowMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/FlowMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/FlowMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface FlowMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface HeaderMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderValuesMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderValuesMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/HeaderValuesMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface HeaderValuesMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/InitParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/InitParameterMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/InitParameterMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/InitParameterMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface InitParameterMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestCookieMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestCookieMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestCookieMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestCookieMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface RequestCookieMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface RequestMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface RequestParameterMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterValuesMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterValuesMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterValuesMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/RequestParameterValuesMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface RequestParameterValuesMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/SessionMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/SessionMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/SessionMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/SessionMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface SessionMap
+{
+
+}
Added: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ViewMap.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ViewMap.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ViewMap.java (added)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/annotation/ViewMap.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package javax.faces.annotation;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface ViewMap
+{
+
+}
Modified: myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIComponent.java?rev=1775568&r1=1775567&r2=1775568&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIComponent.java (original)
+++ myfaces/core/branches/2.3.x/api/src/main/java/javax/faces/component/UIComponent.java Thu Dec 22 01:35:13 2016
@@ -185,7 +185,7 @@ public abstract class UIComponent
* @since 2.2
* @return
*/
- public final Map<String,Object> getPassThroughAttributes()
+ public Map<String,Object> getPassThroughAttributes()
{
return getPassThroughAttributes(true);
}
@@ -1118,7 +1118,7 @@ public abstract class UIComponent
return _stateHelper;
}
- public final TransientStateHelper getTransientStateHelper()
+ public TransientStateHelper getTransientStateHelper()
{
return getTransientStateHelper(true);
}
@@ -1147,7 +1147,7 @@ public abstract class UIComponent
}
@SuppressWarnings("unchecked")
- public final void popComponentFromEL(FacesContext context)
+ public void popComponentFromEL(FacesContext context)
{
Map<Object, Object> contextAttributes = context.getAttributes();
@@ -1264,7 +1264,7 @@ public abstract class UIComponent
}
@SuppressWarnings("unchecked")
- public final void pushComponentToEL(FacesContext context, UIComponent component)
+ public void pushComponentToEL(FacesContext context, UIComponent component)
{
if (component == null)
{
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ComponentBindingExtension.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ComponentBindingExtension.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ComponentBindingExtension.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ComponentBindingExtension.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,76 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.cdi.component;
+
+import java.lang.reflect.Type;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.AnnotatedConstructor;
+import javax.enterprise.inject.spi.AnnotatedField;
+import javax.enterprise.inject.spi.AnnotatedParameter;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessManagedBean;
+
+/**
+ *
+ */
+public class ComponentBindingExtension implements Extension
+{
+
+ private Set<ResolveComponentInfo> types = new HashSet<ResolveComponentInfo>();
+
+ public <T> void collect(@Observes ProcessManagedBean<T> event)
+ {
+ for (AnnotatedField<?> field : event.getAnnotatedBeanClass().getFields())
+ {
+ addAnnotatedTypeIfNecessary(field);
+ }
+
+ for (AnnotatedConstructor<?> constructor : event.getAnnotatedBeanClass().getConstructors())
+ {
+ for (AnnotatedParameter<?> parameter : constructor.getParameters())
+ {
+ addAnnotatedTypeIfNecessary(parameter);
+ }
+ }
+ }
+
+ private void addAnnotatedTypeIfNecessary(Annotated annotated)
+ {
+ if (annotated.isAnnotationPresent(ResolveComponent.class))
+ {
+ Type type = annotated.getBaseType();
+
+ types.add(new ResolveComponentInfo(type, annotated.getAnnotation(ResolveComponent.class).value()));
+ }
+ }
+
+ public void afterBean(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
+ {
+ for (ResolveComponentInfo typeInfo : types)
+ {
+ afterBeanDiscovery.addBean(new DynamicUIComponentProxyProducer(beanManager, typeInfo));
+ }
+ }
+
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/DynamicUIComponentProxyProducer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/DynamicUIComponentProxyProducer.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/DynamicUIComponentProxyProducer.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/DynamicUIComponentProxyProducer.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,204 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.cdi.component;
+
+import java.io.Serializable;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import static java.util.Arrays.asList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Typed;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.PassivationCapable;
+import javax.enterprise.util.AnnotationLiteral;
+import javax.faces.component.ContextCallback;
+import javax.faces.component.UIComponent;
+import javax.faces.component.search.SearchExpressionContext;
+import javax.faces.component.search.SearchExpressionHandler;
+import javax.faces.component.search.SearchExpressionHint;
+import javax.faces.context.FacesContext;
+import org.apache.myfaces.cdi.viewTransient.ViewTransientScoped;
+import org.apache.myfaces.shared.util.ClassUtils;
+
+/**
+ *
+ */
+@Typed
+public class DynamicUIComponentProxyProducer implements Bean<UIComponent>, Serializable, PassivationCapable
+{
+ private static final long serialVersionUID = 1L;
+
+ private BeanManager beanManager;
+ private ResolveComponentInfo typeInfo;
+ private Set<Type> types;
+ private Class<?> beanClass;
+
+ public DynamicUIComponentProxyProducer(BeanManager beanManager, ResolveComponentInfo typeInfo)
+ {
+ this.beanManager = beanManager;
+ this.typeInfo = typeInfo;
+ types = new HashSet<Type>(asList(typeInfo.getType(), Object.class));
+ beanClass = ClassUtils.simpleClassForName(typeInfo.getType().getTypeName());
+ }
+
+ @Override
+ public String getId()
+ {
+ return typeInfo.getType()+"_"+typeInfo.getExpression();
+ }
+
+ public static class DefaultAnnotationLiteral extends AnnotationLiteral<ResolveComponent> implements ResolveComponent
+ {
+ private static final long serialVersionUID = 1L;
+
+ private String value;
+
+ public DefaultAnnotationLiteral(String value)
+ {
+ this.value = value;
+ }
+
+ @Override
+ public String value()
+ {
+ return value;
+ }
+ }
+
+ @Override
+ public Class<?> getBeanClass()
+ {
+ return beanClass;
+ }
+
+ @Override
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+ @Override
+ public Set<Annotation> getQualifiers()
+ {
+ return Collections.singleton((Annotation) new DefaultAnnotationLiteral(typeInfo.getExpression()));
+ }
+
+ @Override
+ public Class<? extends Annotation> getScope()
+ {
+ return ViewTransientScoped.class;
+ }
+
+ @Override
+ public String getName()
+ {
+ return null;
+ }
+
+ @Override
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ @Override
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ @Override
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ @Override
+ public UIComponent create(CreationalContext<UIComponent> creationalContext)
+ {
+ if ("".equals(typeInfo.getExpression()))
+ {
+ return UIComponent.getCurrentComponent(FacesContext.getCurrentInstance());
+ }
+ else
+ {
+ FacesContext facesContext = FacesContext.getCurrentInstance();
+ UIComponent refComponent = UIComponent.getCurrentComponent(facesContext);
+ refComponent = refComponent == null ? facesContext.getViewRoot() : refComponent;
+
+ SearchExpressionHandler handler = facesContext.getApplication().getSearchExpressionHandler();
+ Set<SearchExpressionHint> hints = new HashSet<SearchExpressionHint>();
+ hints.add(SearchExpressionHint.SKIP_VIRTUAL_COMPONENTS);
+ SearchExpressionContext searchContext = SearchExpressionContext.createSearchExpressionContext(
+ facesContext, refComponent, hints, null);
+ FindComponentCallback callback = new FindComponentCallback();
+ handler.resolveComponent(searchContext, typeInfo.getExpression(), callback);
+ return callback.getComponent();
+ }
+ }
+
+ private static class FindComponentCallback implements ContextCallback
+ {
+ private UIComponent component = null;
+
+ @Override
+ public void invokeContextCallback(FacesContext context, UIComponent target)
+ {
+ if (component == null)
+ {
+ component = target;
+ }
+ }
+
+ public UIComponent getComponent()
+ {
+ return component;
+ }
+ }
+
+ @Override
+ public void destroy(UIComponent t, CreationalContext<UIComponent> cc)
+ {
+ }
+
+ public static <A extends Annotation> A getQualifier(InjectionPoint injectionPoint, Class<A> qualifierClass)
+ {
+ for (Annotation annotation : injectionPoint.getQualifiers())
+ {
+ if (qualifierClass.isAssignableFrom(annotation.getClass()))
+ {
+ return qualifierClass.cast(annotation);
+ }
+ }
+
+ return null;
+ }
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponent.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponent.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponent.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponent.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.cdi.component;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.inject.Qualifier;
+
+/**
+ *
+ */
+@Qualifier
+@Retention(value=RetentionPolicy.RUNTIME)
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.PARAMETER, ElementType.FIELD})
+public @interface ResolveComponent
+{
+ public String value() default "";
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponentInfo.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponentInfo.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponentInfo.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/component/ResolveComponentInfo.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,89 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.cdi.component;
+
+import java.io.Serializable;
+import java.lang.reflect.Type;
+import java.util.Objects;
+
+/**
+ *
+ */
+public class ResolveComponentInfo implements Serializable
+{
+
+ private Type type;
+
+ private String expression;
+
+ public ResolveComponentInfo(Type type, String expression)
+ {
+ this.type = type;
+ this.expression = expression;
+ }
+
+ /**
+ * @return the type
+ */
+ public Type getType()
+ {
+ return type;
+ }
+
+ /**
+ * @return the expression
+ */
+ public String getExpression()
+ {
+ return expression;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int hash = 3;
+ hash = 79 * hash + Objects.hashCode(this.type);
+ hash = 79 * hash + Objects.hashCode(this.expression);
+ return hash;
+ }
+
+ @Override
+ public boolean equals(Object obj)
+ {
+ if (obj == null)
+ {
+ return false;
+ }
+ if (getClass() != obj.getClass())
+ {
+ return false;
+ }
+ final ResolveComponentInfo other = (ResolveComponentInfo) obj;
+ if (!Objects.equals(this.type, other.type))
+ {
+ return false;
+ }
+ if (!Objects.equals(this.expression, other.expression))
+ {
+ return false;
+ }
+ return true;
+ }
+
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/ApplicationScopeObjectProducer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/ApplicationScopeObjectProducer.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/ApplicationScopeObjectProducer.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/ApplicationScopeObjectProducer.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.cdi.faces;
+
+import java.util.Map;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.faces.annotation.ApplicationMap;
+import javax.faces.annotation.InitParameterMap;
+import javax.faces.application.Application;
+import javax.faces.application.ResourceHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ *
+ */
+public class ApplicationScopeObjectProducer
+{
+
+ @Produces
+ @ApplicationScoped
+ public Application getApplication()
+ {
+ return FacesContext.getCurrentInstance().getApplication();
+ }
+
+ @Produces
+ @ApplicationMap
+ @ApplicationScoped
+ public Map<String, Object> getApplicationMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+ }
+
+ @Produces
+ @InitParameterMap
+ @ApplicationScoped
+ public Map<String, Object> getInitParameterMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getInitParameterMap();
+ }
+
+ @Produces
+ @ApplicationScoped
+ public ResourceHandler getResourceHandler()
+ {
+ return FacesContext.getCurrentInstance().getApplication().getResourceHandler();
+ }
+}
Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeBeanHolder.java (from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeBeanHolder.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeBeanHolder.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java&r1=1773270&r2=1775568&rev=1775568&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopeBeanHolder.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeBeanHolder.java Thu Dec 22 01:35:13 2016
@@ -16,136 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.flow.cdi;
+package org.apache.myfaces.cdi.faces;
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Collections;
import java.util.HashMap;
-import java.util.List;
import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import javax.annotation.PostConstruct;
-import javax.annotation.PreDestroy;
-import javax.enterprise.context.SessionScoped;
import javax.enterprise.inject.spi.BeanManager;
-import javax.faces.context.ExceptionHandler;
-import javax.faces.context.ExternalContext;
import javax.faces.context.FacesContext;
-import javax.faces.flow.Flow;
-import javax.faces.flow.FlowHandler;
-import javax.faces.lifecycle.ClientWindow;
-import javax.inject.Inject;
-import javax.servlet.ServletContext;
import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
import org.apache.myfaces.cdi.util.ContextualStorage;
-import org.apache.myfaces.cdi.view.ApplicationContextBean;
-import org.apache.myfaces.context.ReleaseableExternalContext;
-import org.apache.myfaces.context.servlet.StartupFacesContextImpl;
-import org.apache.myfaces.context.servlet.StartupServletExternalContextImpl;
-import org.apache.myfaces.flow.util.FlowUtils;
-import org.apache.myfaces.shared.config.MyfacesConfig;
-import org.apache.myfaces.shared.context.ExceptionHandlerImpl;
/**
- *
- * This holder will store the flow scope active ids and it's beans for the current
- * HTTP Session. We use standard SessionScoped bean to not need
- * to treat async-supported and similar headache.
- *
- * @author lu4242
+ * Stateless class to deal with Faces Scope. This scope depends on the current FacesContext.
*/
-@SessionScoped
-public class FlowScopeBeanHolder implements Serializable
+public class FacesScopeBeanHolder
{
- /**
- * key: client window id + flow id
- * value: the {@link ContextualStorage} which holds all the
- * {@link javax.enterprise.inject.spi.Bean}s.
- */
- private Map<String, ContextualStorage> storageMap;
-
- private Map<String, List<String>> activeFlowMapKeys;
-
- private FacesFlowClientWindowCollection windowCollection;
-
- public static final String CURRENT_FLOW_SCOPE_MAP = "oam.CURRENT_FLOW_SCOPE_MAP";
- private static final String FLOW_SCOPE_PREFIX = "oam.flow.SCOPE";
+ public static final String FACES_SCOPE_MAP = "oam.FACES_SCOPE_MAP";
- public static final String FLOW_SCOPE_PREFIX_KEY = FLOW_SCOPE_PREFIX+".KEY";
+ public static final String FACES_SCOPE_MAP_INFO = "oam.FACES_SCOPE_MAP_INFO";
- @Inject
- ApplicationContextBean applicationContextBean;
-
- public FlowScopeBeanHolder()
+ public FacesScopeBeanHolder()
{
}
- @PostConstruct
public void init()
{
- storageMap = new ConcurrentHashMap<String, ContextualStorage>();
- activeFlowMapKeys = new ConcurrentHashMap<String, List<String>>();
- windowCollection = null;
-
- FacesContext facesContext = FacesContext.getCurrentInstance();
- this.refreshClientWindow(facesContext);
- facesContext.getExternalContext().getSessionMap().put(FLOW_SCOPE_PREFIX_KEY,
- 1);
}
/**
* This method will return the ContextualStorage or create a new one
* if no one is yet assigned to the current flowClientWindowId.
* @param beanManager we need the CDI {@link BeanManager} for serialisation.
- * @param flowClientWindowId the flowClientWindowId for the current flow.
+ * @param facesContext the current FacesContext instance
*/
- public ContextualStorage getContextualStorage(BeanManager beanManager, String flowClientWindowId)
+ public static ContextualStorage getContextualStorage(BeanManager beanManager, FacesContext facesContext)
{
- ContextualStorage contextualStorage = storageMap.get(flowClientWindowId);
+ ContextualStorage contextualStorage = (ContextualStorage)
+ facesContext.getAttributes().get(FACES_SCOPE_MAP);
if (contextualStorage == null)
{
- synchronized (this)
- {
- contextualStorage = storageMap.get(flowClientWindowId);
- if (contextualStorage == null)
- {
- contextualStorage = new ContextualStorage(beanManager, true, true);
- storageMap.put(flowClientWindowId, contextualStorage);
- }
- }
+ contextualStorage = new ContextualStorage(beanManager, false, false);
+ facesContext.getAttributes().put(FACES_SCOPE_MAP, contextualStorage);
}
return contextualStorage;
}
- public ContextualStorage getContextualStorageNoCreate(BeanManager beanManager, String flowClientWindowId)
+ public ContextualStorage getContextualStorageNoCreate(BeanManager beanManager, FacesContext facesContext)
{
- return storageMap.get(flowClientWindowId);
+ return (ContextualStorage) facesContext.getAttributes().get(FACES_SCOPE_MAP);
}
- public Map<String, ContextualStorage> getStorageMap()
- {
- return storageMap;
- }
-
- public Map<Object, Object> getFlowScopeMap(
- BeanManager beanManager, String flowClientWindowId, boolean create)
+ public Map<Object, Object> getFacesScopeMap(
+ BeanManager beanManager, FacesContext facesContext, boolean create)
{
Map<Object, Object> map = null;
if (create)
{
ContextualStorage contextualStorage = getContextualStorage(
- beanManager, flowClientWindowId);
- ContextualInstanceInfo info = contextualStorage.getStorage().get(CURRENT_FLOW_SCOPE_MAP);
+ beanManager, facesContext);
+ ContextualInstanceInfo info = contextualStorage.getStorage().get(FACES_SCOPE_MAP_INFO);
if (info == null)
{
info = new ContextualInstanceInfo<Object>();
- contextualStorage.getStorage().put(CURRENT_FLOW_SCOPE_MAP, info);
+ contextualStorage.getStorage().put(FACES_SCOPE_MAP_INFO, info);
}
map = (Map<Object, Object>) info.getContextualInstance();
if (map == null)
@@ -157,10 +92,10 @@ public class FlowScopeBeanHolder impleme
else
{
ContextualStorage contextualStorage = getContextualStorageNoCreate(
- beanManager, flowClientWindowId);
+ beanManager, facesContext);
if (contextualStorage != null)
{
- ContextualInstanceInfo info = contextualStorage.getStorage().get(CURRENT_FLOW_SCOPE_MAP);
+ ContextualInstanceInfo info = contextualStorage.getStorage().get(FACES_SCOPE_MAP_INFO);
if (info != null)
{
map = (Map<Object, Object>) info.getContextualInstance();
@@ -180,11 +115,9 @@ public class FlowScopeBeanHolder impleme
* should be performed on the returned old storage map.
* @return the old storageMap.
*/
- public Map<String, ContextualStorage> forceNewStorage()
+ public ContextualStorage forceNewStorage(FacesContext facesContext)
{
- Map<String, ContextualStorage> oldStorageMap = storageMap;
- storageMap = new ConcurrentHashMap<String, ContextualStorage>();
- return oldStorageMap;
+ return (ContextualStorage) facesContext.getAttributes().remove(FACES_SCOPE_MAP);
}
/**
@@ -195,158 +128,15 @@ public class FlowScopeBeanHolder impleme
* of all it's @WindowScoped beans.
*/
//@PreDestroy
- public void destroyBeans()
+ public void destroyBeans(FacesContext facesContext)
{
// we replace the old windowBeanHolder beans with a new storage Map
// an afterwards destroy the old Beans without having to care about any syncs.
- Map<String, ContextualStorage> oldWindowContextStorages = forceNewStorage();
-
- for (ContextualStorage contextualStorage : oldWindowContextStorages.values())
- {
- FlowScopedContextImpl.destroyAllActive(contextualStorage);
- }
- }
-
- /**
- * See description on ViewScopeBeanHolder for details about how this works
- */
- @PreDestroy
- public void destroyBeansOnPreDestroy()
- {
- Map<String, ContextualStorage> oldWindowContextStorages = forceNewStorage();
- if (!oldWindowContextStorages.isEmpty())
- {
- FacesContext facesContext = FacesContext.getCurrentInstance();
- ServletContext servletContext = null;
- if (facesContext == null)
- {
- try
- {
- servletContext = applicationContextBean.getServletContext();
- }
- catch (Throwable e)
- {
- Logger.getLogger(FlowScopeBeanHolder.class.getName()).log(Level.WARNING,
- "Cannot locate servletContext to create FacesContext on @PreDestroy flow scope beans. "
- + "The beans will be destroyed without active FacesContext instance.");
- servletContext = null;
- }
- }
- if (facesContext == null &&
- servletContext != null)
- {
- try
- {
- ExternalContext externalContext = new StartupServletExternalContextImpl(servletContext, false);
- ExceptionHandler exceptionHandler = new ExceptionHandlerImpl();
- facesContext = new StartupFacesContextImpl(externalContext,
- (ReleaseableExternalContext) externalContext, exceptionHandler, false);
- for (ContextualStorage contextualStorage : oldWindowContextStorages.values())
- {
- FlowScopedContextImpl.destroyAllActive(contextualStorage);
- }
- }
- finally
- {
- facesContext.release();
- }
- }
- else
- {
- for (ContextualStorage contextualStorage : oldWindowContextStorages.values())
- {
- FlowScopedContextImpl.destroyAllActive(contextualStorage);
- }
- }
- }
- }
-
- public void refreshClientWindow(FacesContext facesContext)
- {
- if (windowCollection == null)
+ ContextualStorage oldWindowContextStorages = forceNewStorage(facesContext);
+ if (oldWindowContextStorages != null)
{
- Integer ft = MyfacesConfig.getCurrentInstance(facesContext.getExternalContext()).
- getNumberOfFacesFlowClientWindowIdsInSession();
- windowCollection = new FacesFlowClientWindowCollection(new ClientWindowFacesFlowLRUMap(ft));
- }
- ClientWindow cw = facesContext.getExternalContext().getClientWindow();
- if (cw != null && cw.getId() != null)
- {
- windowCollection.setFlowScopeBeanHolder(this);
- windowCollection.put(cw.getId(), "");
+ FacesScopedContextImpl.destroyAllActive(oldWindowContextStorages);
}
}
-
- public void clearFlowMap(String clientWindowId)
- {
- List<String> activeFlowKeys = activeFlowMapKeys.remove(clientWindowId);
- if (activeFlowKeys != null && !activeFlowKeys.isEmpty())
- {
- for (String flowMapKey : activeFlowKeys)
- {
- ContextualStorage contextualStorage = storageMap.remove(flowMapKey);
- if (contextualStorage != null)
- {
- FlowScopedContextImpl.destroyAllActive(contextualStorage);
- }
- }
- }
- }
-
- public List<String> getActiveFlowMapKeys(FacesContext facesContext)
- {
- ClientWindow cw = facesContext.getExternalContext().getClientWindow();
- String baseKey = cw.getId();
- List<String> activeFlowKeys = activeFlowMapKeys.get(baseKey);
- if (activeFlowKeys == null)
- {
- return Collections.emptyList();
- }
- else
- {
- return activeFlowKeys;
- }
- }
-
- public void createCurrentFlowScope(FacesContext facesContext)
- {
- ClientWindow cw = facesContext.getExternalContext().getClientWindow();
- String baseKey = cw.getId();
-
- FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
- Flow flow = flowHandler.getCurrentFlow(facesContext);
- String flowMapKey = FlowUtils.getFlowMapKey(facesContext, flow);
-
- List<String> activeFlowKeys = activeFlowMapKeys.get(baseKey);
- if (activeFlowKeys == null)
- {
- activeFlowKeys = new ArrayList<String>();
-
- }
- activeFlowKeys.add(0, flowMapKey);
- activeFlowMapKeys.put(baseKey, activeFlowKeys);
- refreshClientWindow(facesContext);
- }
-
- public void destroyCurrentFlowScope(FacesContext facesContext)
- {
- ClientWindow cw = facesContext.getExternalContext().getClientWindow();
- String baseKey = cw.getId();
-
- FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
- Flow flow = flowHandler.getCurrentFlow(facesContext);
- String flowMapKey = FlowUtils.getFlowMapKey(facesContext, flow);
- ContextualStorage contextualStorage = storageMap.remove(flowMapKey);
- if (contextualStorage != null)
- {
- FlowScopedContextImpl.destroyAllActive(contextualStorage);
- }
-
- List<String> activeFlowKeys = activeFlowMapKeys.get(baseKey);
- if (activeFlowKeys != null && !activeFlowKeys.isEmpty())
- {
- activeFlowKeys.remove(flowMapKey);
- }
- }
}
Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeContextExtension.java (from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeContextExtension.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeContextExtension.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java&r1=1773270&r2=1775568&rev=1775568&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/view/ViewScopeContextExtension.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeContextExtension.java Thu Dec 22 01:35:13 2016
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.cdi.view;
+package org.apache.myfaces.cdi.faces;
import javax.enterprise.event.Observes;
import javax.enterprise.inject.spi.AfterBeanDiscovery;
@@ -24,32 +24,32 @@ import javax.enterprise.inject.spi.Annot
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.BeforeBeanDiscovery;
import javax.enterprise.inject.spi.Extension;
-import javax.faces.view.ViewScoped;
/**
- * Handle ViewScope related features.
+ * Handle FacesScoped related features.
*
- * @author Leonardo Uribe
*/
-public class ViewScopeContextExtension implements Extension
+public class FacesScopeContextExtension implements Extension
{
- private ViewScopeContextImpl viewScopeContext;
+ private FacesScopedContextImpl facesScopeContext;
void beforeBeanDiscovery(
@Observes final BeforeBeanDiscovery event, BeanManager beanManager)
{
- event.addScope(ViewScoped.class, true, true);
- // Register ViewScopeBeanHolder as a bean with CDI annotations, so the system
- // can take it into account, and use it later when necessary.
- AnnotatedType appContext = beanManager.createAnnotatedType(ApplicationContextBean.class);
- event.addAnnotatedType(appContext);
- AnnotatedType bean = beanManager.createAnnotatedType(ViewScopeBeanHolder.class);
- event.addAnnotatedType(bean);
+ event.addScope(FacesScoped.class, true, false);
+
+ AnnotatedType<FacesScopeObjectProducer> flowDiscoveryHelper =
+ beanManager.createAnnotatedType(FacesScopeObjectProducer.class);
+ event.addAnnotatedType(flowDiscoveryHelper);
+
+ AnnotatedType<ApplicationScopeObjectProducer> applicationScopeObjectProducer =
+ beanManager.createAnnotatedType(ApplicationScopeObjectProducer.class);
+ event.addAnnotatedType(applicationScopeObjectProducer);
}
void afterBeanDiscovery(@Observes AfterBeanDiscovery afterBeanDiscovery, BeanManager beanManager)
{
- viewScopeContext = new ViewScopeContextImpl(beanManager);
- afterBeanDiscovery.addContext(viewScopeContext);
+ facesScopeContext = new FacesScopedContextImpl(beanManager);
+ afterBeanDiscovery.addContext(facesScopeContext);
}
}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeObjectProducer.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeObjectProducer.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeObjectProducer.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeObjectProducer.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,120 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.cdi.faces;
+
+import java.util.Map;
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.Produces;
+import javax.faces.annotation.HeaderMap;
+import javax.faces.annotation.HeaderValuesMap;
+import javax.faces.annotation.RequestCookieMap;
+import javax.faces.annotation.RequestMap;
+import javax.faces.annotation.RequestParameterMap;
+import javax.faces.annotation.RequestParameterValuesMap;
+import javax.faces.annotation.SessionMap;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.FacesContext;
+import javax.faces.context.Flash;
+
+/**
+ * This class produces all objects that are bound or related to FacesContext
+ */
+@ApplicationScoped
+public class FacesScopeObjectProducer
+{
+
+ @Produces
+ @FacesScoped
+ public FacesContext getFacesContext()
+ {
+ return FacesContext.getCurrentInstance();
+ }
+
+ @Produces
+ @FacesScoped
+ public ExternalContext getExternalContext()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext();
+ }
+
+ @Produces
+ @FacesScoped
+ public Flash getFlash()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getFlash();
+ }
+
+ @Produces
+ @HeaderMap
+ @FacesScoped
+ public Map<String, String> getHeaderMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderMap();
+ }
+
+ @Produces
+ @HeaderValuesMap
+ @FacesScoped
+ public Map<String, String[]> getHeaderValuesMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestHeaderValuesMap();
+ }
+
+ @Produces
+ @RequestMap
+ @FacesScoped
+ public Map<String, Object> getRequestMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ }
+
+ @Produces
+ @RequestCookieMap
+ @FacesScoped
+ public Map<String, Object> getRequestCookieMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestCookieMap();
+ }
+
+ @Produces
+ @RequestParameterMap
+ @FacesScoped
+ public Map<String, String> getRequestParameterMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap();
+ }
+
+ @Produces
+ @RequestParameterValuesMap
+ @FacesScoped
+ public Map<String, String[]> getRequestParameterValuesMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getRequestParameterValuesMap();
+ }
+
+ @Produces
+ @SessionMap
+ @FacesScoped
+ public Map<String, Object> getSessionMap()
+ {
+ return FacesContext.getCurrentInstance().getExternalContext().getSessionMap();
+ }
+
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeProvider.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeProvider.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeProvider.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopeProvider.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,36 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.myfaces.cdi.faces;
+
+import javax.faces.context.FacesContext;
+
+
+/**
+ * This class is used to destroy FacesScoped beans when FacesContext is destroyed.
+ */
+public class FacesScopeProvider
+{
+
+ public static void destroyBeans(FacesContext facesContext)
+ {
+ FacesScopeBeanHolder holder = new FacesScopeBeanHolder();
+ holder.destroyBeans(facesContext);
+ }
+}
Added: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScoped.java
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScoped.java?rev=1775568&view=auto
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScoped.java (added)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScoped.java Thu Dec 22 01:35:13 2016
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.cdi.faces;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import javax.enterprise.context.NormalScope;
+
+/**
+ *
+ */
+@NormalScope
+@Inherited
+@Documented
+@Target(value={ElementType.TYPE, ElementType.METHOD, ElementType.FIELD})
+@Retention(value= RetentionPolicy.RUNTIME)
+public @interface FacesScoped
+{
+
+}
Copied: myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopedContextImpl.java (from r1773270, myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java)
URL: http://svn.apache.org/viewvc/myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopedContextImpl.java?p2=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopedContextImpl.java&p1=myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java&r1=1773270&r2=1775568&rev=1775568&view=diff
==============================================================================
--- myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/flow/cdi/FlowScopedContextImpl.java (original)
+++ myfaces/core/branches/2.3.x/impl/src/main/java/org/apache/myfaces/cdi/faces/FacesScopedContextImpl.java Thu Dec 22 01:35:13 2016
@@ -16,134 +16,71 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.myfaces.flow.cdi;
+package org.apache.myfaces.cdi.faces;
import java.lang.annotation.Annotation;
-import java.util.List;
import java.util.Map;
import javax.enterprise.context.ContextNotActiveException;
import javax.enterprise.context.spi.Context;
import javax.enterprise.context.spi.Contextual;
import javax.enterprise.context.spi.CreationalContext;
import javax.enterprise.inject.Typed;
-import javax.enterprise.inject.spi.Bean;
import javax.enterprise.inject.spi.BeanManager;
import javax.enterprise.inject.spi.PassivationCapable;
import javax.faces.context.FacesContext;
-import javax.faces.flow.Flow;
-import javax.faces.flow.FlowHandler;
-import javax.faces.flow.FlowScoped;
-import org.apache.myfaces.cdi.util.BeanProvider;
import org.apache.myfaces.cdi.util.ContextualInstanceInfo;
import org.apache.myfaces.cdi.util.ContextualStorage;
-import org.apache.myfaces.flow.FlowReference;
-import org.apache.myfaces.flow.util.FlowUtils;
/**
- * Minimal implementation of FlowScope.
- *
- * @TODO: We need something better for this part. The problem is the beans
- * are just put under the session map using the old know SubKeyMap hack used
- * in Flash object, but CDI implementations like OWB solves the passivation
- * problem better. The ideal is provide a myfaces specific SPI interface, to
- * allow provide custom implementation of this detail.
- *
- * @TODO: FlowHandler.transition() method should call this object when the
- * user enter or exit a flow.
- *
- * @author Leonardo Uribe
+ * Minimal implementation of FacesScope.
*/
@Typed()
-public class FlowScopedContextImpl implements Context
+public class FacesScopedContextImpl implements Context
{
- /**
- * Whether the Context is for a passivating scope.
- */
- private final boolean passivatingScope;
- /**
- * needed for serialisation and passivationId
- */
private BeanManager beanManager;
- private Map<Class, FlowReference> flowBeanReferences;
-
- //private FlowScopeBeanHolder flowScopeBeanHolder;
-
- public FlowScopedContextImpl(BeanManager beanManager,
- Map<Class, FlowReference> flowBeanReferences)
+ public FacesScopedContextImpl(BeanManager beanManager)
{
this.beanManager = beanManager;
- this.flowBeanReferences = flowBeanReferences;
- passivatingScope = beanManager.isPassivatingScope(getScope());
}
- /*
- public void initFlowContext(FlowScopeBeanHolder flowScopeBeanHolder)
- {
- this.flowScopeBeanHolder = flowScopeBeanHolder;
- }*/
-
- protected FlowScopeBeanHolder getFlowScopeBeanHolder()
+ protected FacesScopeBeanHolder getFlowScopeBeanHolder()
{
return getFlowScopeBeanHolder(FacesContext.getCurrentInstance());
}
- protected FlowScopeBeanHolder getFlowScopeBeanHolder(FacesContext facesContext)
+ protected FacesScopeBeanHolder getFlowScopeBeanHolder(FacesContext facesContext)
{
- FlowScopeBeanHolder flowScopeBeanHolder = (FlowScopeBeanHolder)
- facesContext.getExternalContext().getApplicationMap().get(
- "oam.flow.FlowScopeBeanHolder");
- if (flowScopeBeanHolder == null)
- {
- flowScopeBeanHolder = BeanProvider.getContextualReference(
- beanManager, FlowScopeBeanHolder.class, false);
- facesContext.getExternalContext().getApplicationMap().put(
- "oam.flow.FlowScopeBeanHolder", flowScopeBeanHolder);
- }
- return flowScopeBeanHolder;
+ return new FacesScopeBeanHolder();
}
- public String getCurrentClientWindowFlowId(FacesContext facesContext)
- {
- String flowMapKey = null;
- FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
- Flow flow = flowHandler.getCurrentFlow(facesContext);
- if (flow != null)
- {
- flowMapKey = FlowUtils.getFlowMapKey(facesContext, flow);
- }
- return flowMapKey;
- }
-
/**
* An implementation has to return the underlying storage which
* contains the items held in the Context.
* @param createIfNotExist whether a ContextualStorage shall get created if it doesn't yet exist.
* @return the underlying storage
*/
- protected ContextualStorage getContextualStorage(boolean createIfNotExist, String clientWindowFlowId)
+ protected ContextualStorage getContextualStorage(boolean createIfNotExist, FacesContext facesContext)
{
- //FacesContext facesContext = FacesContext.getCurrentInstance();
- //String clientWindowFlowId = getCurrentClientWindowFlowId(facesContext);
- if (clientWindowFlowId == null)
+ if (facesContext == null)
{
- throw new ContextNotActiveException("FlowScopedContextImpl: no current active flow");
+ throw new ContextNotActiveException("FacesScopedContextImpl: no current active facesContext");
}
if (createIfNotExist)
{
- return getFlowScopeBeanHolder().getContextualStorage(beanManager, clientWindowFlowId);
+ return getFlowScopeBeanHolder(facesContext).getContextualStorage(beanManager, facesContext);
}
else
{
- return getFlowScopeBeanHolder().getContextualStorageNoCreate(beanManager, clientWindowFlowId);
+ return getFlowScopeBeanHolder(facesContext).getContextualStorageNoCreate(beanManager, facesContext);
}
}
public Class<? extends Annotation> getScope()
{
- return FlowScoped.class;
+ return FacesScoped.class;
}
public boolean isActive()
@@ -157,18 +94,7 @@ public class FlowScopedContextImpl imple
{
return false;
}
- Flow flow = facesContext.getApplication().
- getFlowHandler().getCurrentFlow(facesContext);
-
- return flow != null;
- }
-
- /**
- * @return whether the served scope is a passivating scope
- */
- public boolean isPassivatingScope()
- {
- return passivatingScope;
+ return true;
}
@Override
@@ -178,149 +104,41 @@ public class FlowScopedContextImpl imple
checkActive(facesContext);
-
- FlowReference reference = flowBeanReferences.get(((Bean)bean).getBeanClass());
- if (reference != null)
+ if (facesContext != null)
{
- String flowMapKey = FlowUtils.getFlowMapKey(facesContext, reference);
- if (flowMapKey != null)
+ ContextualStorage storage = getContextualStorage(false, facesContext);
+ if (storage != null)
{
- ContextualStorage storage = getContextualStorage(false, flowMapKey);
- if (storage != null)
- {
- Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
- ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
+ Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
+ ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
- if (contextualInstanceInfo != null)
- {
- return (T) contextualInstanceInfo.getContextualInstance();
- }
+ if (contextualInstanceInfo != null)
+ {
+ return (T) contextualInstanceInfo.getContextualInstance();
}
}
- else
- {
- throw new IllegalStateException("Flow "+ reference.getId()+
- " cannot be found when resolving bean " +bean.toString());
- }
}
-
- List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
- for (String flowMapKey : activeFlowMapKeys)
+ else
{
- ContextualStorage storage = getContextualStorage(false, flowMapKey);
- if (storage == null)
- {
- //return null;
- continue;
- }
-
- Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
- ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
- if (contextualInstanceInfo == null)
- {
- //return null;
- continue;
- }
-
- return (T) contextualInstanceInfo.getContextualInstance();
+ throw new IllegalStateException("FacesContext cannot be found when resolving bean " +bean.toString());
}
return null;
}
- @Override
public <T> T get(Contextual<T> bean, CreationalContext<T> creationalContext)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
checkActive(facesContext);
- if (passivatingScope && !(bean instanceof PassivationCapable))
+ if (!(bean instanceof PassivationCapable))
{
throw new IllegalStateException(bean.toString() +
" doesn't implement " + PassivationCapable.class.getName());
}
-
- FlowReference reference = flowBeanReferences.get(((Bean)bean).getBeanClass());
- if (reference != null)
- {
- String flowMapKey = FlowUtils.getFlowMapKey(facesContext, reference);
- if (flowMapKey != null)
- {
- ContextualStorage storage = getContextualStorage(false, flowMapKey);
- if (storage != null)
- {
- Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
- ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
- if (contextualInstanceInfo != null)
- {
- return (T) contextualInstanceInfo.getContextualInstance();
- }
- }
- }
- else
- {
- throw new IllegalStateException("Flow "+ reference.getId()+
- " cannot be found when resolving bean " + bean.toString());
- }
-
- FlowHandler flowHandler = facesContext.getApplication().getFlowHandler();
- // Since it is possible to have only the flow id without documentId, the best
- // is first get the flow using flowHandler.getFlow and then check if the flow is
- // active or not, but using the documentId and id of the retrieved flow.
- Flow flow = flowHandler.getFlow(facesContext,
- reference.getDocumentId() == null ? "" : reference.getDocumentId(), reference.getId());
- if (flow == null)
- {
- throw new IllegalStateException(bean.toString() + "cannot be created because flow "+ reference.getId()+
- " is not registered");
- }
- if (!flowHandler.isActive(facesContext, flow.getDefiningDocumentId(), flow.getId()))
- {
- throw new IllegalStateException(bean.toString() + "cannot be created if flow "+ reference.getId()+
- " is not active");
- }
-
- ContextualStorage storage = getContextualStorage(true, flowMapKey);
- Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
- ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
-
- if (contextualInstanceInfo != null)
- {
- @SuppressWarnings("unchecked")
- final T instance = (T) contextualInstanceInfo.getContextualInstance();
-
- if (instance != null)
- {
- return instance;
- }
- }
-
- return storage.createContextualInstance(bean, creationalContext);
- }
-
- List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
- for (String flowMapKey : activeFlowMapKeys)
- {
- ContextualStorage storage = getContextualStorage(false, flowMapKey);
-
- Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
- ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
- if (contextualInstanceInfo != null)
- {
- @SuppressWarnings("unchecked")
- final T instance = (T) contextualInstanceInfo.getContextualInstance();
+ ContextualStorage storage = getContextualStorage(true, facesContext);
- if (instance != null)
- {
- return instance;
- }
- }
-
- }
-
- ContextualStorage storage = getContextualStorage(true, getCurrentClientWindowFlowId(facesContext));
Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
ContextualInstanceInfo<?> contextualInstanceInfo = contextMap.get(storage.getBeanKey(bean));
@@ -334,7 +152,7 @@ public class FlowScopedContextImpl imple
return instance;
}
}
-
+
return storage.createContextualInstance(bean, creationalContext);
}
@@ -346,44 +164,21 @@ public class FlowScopedContextImpl imple
public boolean destroy(Contextual bean)
{
FacesContext facesContext = FacesContext.getCurrentInstance();
- List<String> activeFlowMapKeys = getFlowScopeBeanHolder().getActiveFlowMapKeys(facesContext);
- for (String flowMapKey : activeFlowMapKeys)
+ ContextualStorage storage = getContextualStorage(false, facesContext);
+ if (storage == null)
{
- ContextualStorage storage = getContextualStorage(false, flowMapKey);
- if (storage == null)
- {
- //return false;
- continue;
- }
- ContextualInstanceInfo<?> contextualInstanceInfo = storage.getStorage().get(storage.getBeanKey(bean));
-
- if (contextualInstanceInfo == null)
- {
- //return false;
- continue;
- }
-
- bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
- return true;
+ return false;
}
- return false;
- }
+ ContextualInstanceInfo<?> contextualInstanceInfo = storage.getStorage().get(storage.getBeanKey(bean));
- /**
- * destroys all the Contextual Instances in the Storage returned by
- * {@link #getContextualStorage(boolean)}.
- */
- /*
- public void destroyAllActive()
- {
- ContextualStorage storage = getContextualStorage(false);
- if (storage == null)
+ if (contextualInstanceInfo == null)
{
- return;
+ return false;
}
- destroyAllActive(storage);
- }*/
+ bean.destroy(contextualInstanceInfo.getContextualInstance(), contextualInstanceInfo.getCreationalContext());
+ return true;
+ }
/**
* Destroys all the Contextual Instances in the specified ContextualStorage.
@@ -395,7 +190,7 @@ public class FlowScopedContextImpl imple
Map<Object, ContextualInstanceInfo<?>> contextMap = storage.getStorage();
for (Map.Entry<Object, ContextualInstanceInfo<?>> entry : contextMap.entrySet())
{
- if (!FlowScopeBeanHolder.CURRENT_FLOW_SCOPE_MAP.equals(entry.getKey()))
+ if (!FacesScopeBeanHolder.FACES_SCOPE_MAP_INFO.equals(entry.getKey()))
{
Contextual bean = storage.getBean(entry.getKey());