empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1459187 - in /empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app: FacesImplementation.java FacesUtils.java impl/MojarraImplementation.java impl/MyFacesImplementation.java
Date Thu, 21 Mar 2013 08:22:27 GMT
Author: doebele
Date: Thu Mar 21 08:22:26 2013
New Revision: 1459187

URL: http://svn.apache.org/r1459187
Log:
EMPIREDB-180
Added License headers

Modified:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java?rev=1459187&r1=1459186&r2=1459187&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
Thu Mar 21 08:22:26 2013
@@ -1,7 +1,26 @@
+/*
+ * 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.empire.jsf2.app;
 
 import javax.el.ValueExpression;
 import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
 
 public interface FacesImplementation 
 {
@@ -16,7 +35,7 @@ public interface FacesImplementation 
      *	application.setImplementation(this, applFactoryImpl.getApplication());
      *	applFactoryImpl.setApplication(application);
 	 */
-	void initApplication(FacesApplication application);
+	void initApplication(final FacesApplication application);
 
 	/**
 	 *	Registers a managed bean	
@@ -48,7 +67,19 @@ public interface FacesImplementation 
      *	rc.addManagedBean(beanName, mbi);
      *  
 	 */
-	void registerManagedBean(String beanName, String beanClass, String scope);
+	void registerManagedBean(final String beanName, final String beanClass, final String scope);
+	
+	/**
+	 *	Returns the parentComponent for a given ValueExpression.
+	 *
+	 *	Implementation example:
+	 *	-----------------------
+     *  final ELContext elcontext = fc.getELContext();
+     *  final Application application = fc.getApplication();
+     *  return application.getELResolver().getValue(elcontext, null, beanName);
+	 * 
+	 */
+	public Object getManagedBean(final String beanName, final FacesContext fc);
 	
 	/**
 	 *	Return the parentComponent for a given ValueExpression.
@@ -65,6 +96,6 @@ public interface FacesImplementation 
      *      return cc;
      *  }
 	 */
-	UIComponent getValueParentComponent(ValueExpression ve);
+	UIComponent getValueParentComponent(final ValueExpression ve);
 	
 }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java?rev=1459187&r1=1459186&r2=1459187&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesUtils.java
Thu Mar 21 08:22:26 2013
@@ -24,7 +24,6 @@ import java.sql.Connection;
 import java.util.HashMap;
 import java.util.Map;
 
-import javax.el.ELContext;
 import javax.faces.FactoryFinder;
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
@@ -198,11 +197,12 @@ public class FacesUtils
         {
             throw new NullPointerException("name must not be null");
         }
-
+        /*
         final ELContext elcontext = fc.getELContext();
         final Application application = fc.getApplication();
-
         return application.getELResolver().getValue(elcontext, null, name);
+        */
+        return getFacesApplication().getFacesImplementation().getManagedBean(name, fc);
     }
     
     public static <T> T getManagedBean(final FacesContext fc, final Class<T>
cls)

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java?rev=1459187&r1=1459186&r2=1459187&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
Thu Mar 21 08:22:26 2013
@@ -1,3 +1,21 @@
+/*
+ * 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.empire.jsf2.app.impl;
 
 import java.util.Map;
@@ -20,9 +38,10 @@ import com.sun.faces.mgbean.ManagedBeanI
 
 public class MojarraImplementation implements FacesImplementation 
 {
+	private BeanManager bm;
 
 	@Override
-	public void initApplication(FacesApplication application)
+	public void initApplication(final FacesApplication application)
 	{
 		ApplicationFactoryImpl applFactoryImpl = new ApplicationFactoryImpl();
         // set impl
@@ -30,13 +49,14 @@ public class MojarraImplementation imple
         // Application Map 
         Map<String, Object> appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
         appMap.put(InjectionApplicationFactory.class.getName(), application);
+        // init Bean Manager
+		FacesContext fc = FacesContext.getCurrentInstance();
+		bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager();
 	}
 
 	@Override
-	public void registerManagedBean(String beanName, String beanClass, String scope) 
+	public void registerManagedBean(final String beanName,final String beanClass,final String
scope) 
 	{
-		FacesContext fc = FacesContext.getCurrentInstance();
-		BeanManager  bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager();
 		// check
         if (bm.getRegisteredBeans().containsKey(beanName))
         {
@@ -48,7 +68,17 @@ public class MojarraImplementation imple
 	}
 
 	@Override
-	public UIComponent getValueParentComponent(ValueExpression ve) 
+	public Object getManagedBean(final String beanName, final FacesContext fc)
+	{
+		// Find Bean
+		Object mbean = bm.getBeanFromScope(beanName, fc);
+		if (mbean==null)
+			mbean= bm.create(beanName, fc);
+        return mbean;
+	}
+	
+	@Override
+	public UIComponent getValueParentComponent(final ValueExpression ve) 
 	{
         if (ve instanceof ContextualCompositeValueExpression)
         {

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java?rev=1459187&r1=1459186&r2=1459187&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
Thu Mar 21 08:22:26 2013
@@ -1,6 +1,26 @@
+/*
+ * 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.empire.jsf2.app.impl;
 
+import javax.el.ELContext;
 import javax.el.ValueExpression;
+import javax.faces.application.Application;
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 
@@ -13,7 +33,6 @@ import org.apache.myfaces.config.impl.di
 
 public class MyFacesImplementation implements FacesImplementation 
 {
-	
 	@Override
 	public void initApplication(FacesApplication application)
 	{
@@ -24,8 +43,9 @@ public class MyFacesImplementation imple
 	}
 
 	@Override
-	public void registerManagedBean(String beanName, String beanClass, String scope) {
+	public void registerManagedBean(final String beanName, final String beanClass, final String
scope) {
 		
+        // get Runtime Config
 		FacesContext  fc = FacesContext.getCurrentInstance();
 		RuntimeConfig rc = RuntimeConfig.getCurrentInstance(fc.getExternalContext());
 		// check
@@ -42,7 +62,16 @@ public class MyFacesImplementation imple
 	}
 
 	@Override
-	public UIComponent getValueParentComponent(ValueExpression ve)
+	public Object getManagedBean(final String beanName, final FacesContext fc)
+	{
+		// Find Bean
+        final ELContext elcontext = fc.getELContext();
+        final Application application = fc.getApplication();
+        return application.getELResolver().getValue(elcontext, null, beanName);
+	}
+
+	@Override
+	public UIComponent getValueParentComponent(final ValueExpression ve)
 	{
 		/* No implmentation for MyFaces currently available */
 		return null;



Mime
View raw message