empire-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From doeb...@apache.org
Subject svn commit: r1458973 - in /empire-db/trunk: ./ empire-db-examples/empire-db-example-jsf2/ empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/ empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache...
Date Wed, 20 Mar 2013 17:36:24 GMT
Author: doebele
Date: Wed Mar 20 17:36:23 2013
New Revision: 1458973

URL: http://svn.apache.org/r1458973
Log:
EMPIREDB-180
Allow JSF extentions to be used with Apache MyFaces

Added:
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
  (with props)
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
  (with props)
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
  (with props)
Modified:
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/pom.xml
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/FileInputControl.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplicationFactory.java
    empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/WEB-INF/facelets/templates/layout.xhtml
    empire-db/trunk/empire-db-jsf2/pom.xml
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplicationFactory.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
    empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
    empire-db/trunk/pom.xml

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/pom.xml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/pom.xml?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/pom.xml (original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/pom.xml Wed Mar 20 17:36:23
2013
@@ -38,11 +38,19 @@
 			<artifactId>empire-db</artifactId>
 		</dependency>
 
-		<!-- java server faces -->
+		<dependency>
+			<groupId>org.apache.empire-db</groupId>
+			<artifactId>empire-db-jsf2</artifactId>
+		</dependency>
+
 		<dependency>
 			<groupId>javax.servlet</groupId>
 			<artifactId>servlet-api</artifactId>
+			<scope>provided</scope>
 		</dependency>
+
+		<!-- Sun Mojarra -->
+		<!-- 		
 		<dependency>
 			<groupId>com.sun.faces</groupId>
 			<artifactId>jsf-api</artifactId>
@@ -51,12 +59,18 @@
 			<groupId>com.sun.faces</groupId>
 			<artifactId>jsf-impl</artifactId>
 		</dependency>
+		 -->
+
+		<!-- Apache MyFaces -->
 		<dependency>
-			<groupId>org.apache.empire-db</groupId>
-			<artifactId>empire-db-jsf2</artifactId>
+			<groupId>org.apache.myfaces.core</groupId>
+			<artifactId>myfaces-api</artifactId>
+		</dependency>
+		<dependency>
+			<groupId>org.apache.myfaces.core</groupId>
+			<artifactId>myfaces-impl</artifactId>
 		</dependency>
 
-		<!-- myfaces -->
 		<dependency>
 			<groupId>org.apache.tomcat</groupId>
 			<artifactId>el-api</artifactId>

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/FileInputControl.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/FileInputControl.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/FileInputControl.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/custom/controls/FileInputControl.java
Wed Mar 20 17:36:23 2013
@@ -18,23 +18,15 @@
  */
 package org.apache.empire.jsf2.custom.controls;
 
-import java.io.IOException;
 import java.util.List;
 
 import javax.faces.component.UIComponent;
 import javax.faces.component.html.HtmlInputText;
 import javax.faces.context.FacesContext;
-import javax.faces.context.ResponseWriter;
-import javax.faces.convert.ConverterException;
 
 import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.jsf2.controls.InputControl;
 
-import com.sun.faces.renderkit.Attribute;
-import com.sun.faces.renderkit.AttributeManager;
-import com.sun.faces.renderkit.RenderKitUtils;
-import com.sun.faces.renderkit.html_basic.TextRenderer;
-
 public class FileInputControl extends InputControl
 {
     public static final String             NAME                = "blob";
@@ -87,6 +79,7 @@ public class FileInputControl extends In
         }
     }
 
+    /*
     public class FileInputRenderer extends TextRenderer
     {
 
@@ -149,5 +142,6 @@ public class FileInputControl extends In
         }
 
     }
+    */
 
 }

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplication.java
Wed Mar 20 17:36:23 2013
@@ -44,9 +44,6 @@ import org.apache.empire.jsf2.websample.
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.faces.application.ApplicationAssociate;
-import com.sun.faces.mgbean.BeanManager;
-
 public class SampleApplication extends FacesApplication {
 	// Logger
 	private static final Logger log = LoggerFactory
@@ -186,8 +183,8 @@ public class SampleApplication extends F
 	}
 
 	private void initPages(ServletContext sc) {
-		BeanManager bm = ApplicationAssociate.getInstance(sc).getBeanManager();
-		new SamplePages().registerPageBeans(bm);
+		// register Page Beans
+		new SamplePages().registerPageBeans(this.getFacesImplemenation());
 	}
 
 	public SampleDB getDatabase() {

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplicationFactory.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplicationFactory.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplicationFactory.java
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/java/org/apache/empire/jsf2/websample/web/SampleApplicationFactory.java
Wed Mar 20 17:36:23 2013
@@ -18,52 +18,16 @@
  */
 package org.apache.empire.jsf2.websample.web;
 
-import java.util.Map;
+import org.apache.empire.jsf2.app.FacesApplicationFactory;
 
-import javax.faces.application.Application;
-import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
-
-import org.apache.empire.exceptions.InvalidArgumentException;
-import org.apache.empire.exceptions.ItemExistsException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.sun.faces.application.InjectionApplicationFactory;
-
-public class SampleApplicationFactory extends ApplicationFactory
+/**
+ * The Application factory for this application
+ * @author doebele
+ */
+public class SampleApplicationFactory extends FacesApplicationFactory
 {
-    private static final Logger  log = LoggerFactory.getLogger(SampleApplicationFactory.class);
-    private volatile Application application;
-
     public SampleApplicationFactory()
     {
-        log.info("SampleApplicationFactory created");
-    }
-
-    @Override
-    public Application getApplication()
-    {
-        if (application == null)
-        { // Create Application
-            application = new SampleApplication();
-            // InjectionApplicationFactory.setApplicationInstance(application);
-            Map<String, Object> appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
-            appMap.put(InjectionApplicationFactory.class.getName(), application);
-            // log
-            log.info("Fin2Application Application instance created");
-        }
-        return application;
-    }
-
-    @Override
-    public void setApplication(Application application)
-    {
-        if (this.application != null)
-            throw new ItemExistsException(this.application);
-        if (!(application instanceof SampleApplication))
-            throw new InvalidArgumentException("application", application);
-        this.application = application;
+    	super(SampleApplication.class);
     }
-
 }

Modified: empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/WEB-INF/facelets/templates/layout.xhtml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/WEB-INF/facelets/templates/layout.xhtml?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/WEB-INF/facelets/templates/layout.xhtml
(original)
+++ empire-db/trunk/empire-db-examples/empire-db-example-jsf2/src/main/webapp/WEB-INF/facelets/templates/layout.xhtml
Wed Mar 20 17:36:23 2013
@@ -27,6 +27,9 @@
 <f:view locale="#{sampleUser.locale}" />
 <ui:param name="webRoot" value=".." />
 
+<f:metadata>
+	<ui:insert name="metadata" />
+</f:metadata>
 
 <h:head>
 
@@ -54,10 +57,6 @@
 <h:body>
 	<f:view>
 
-		<f:metadata>
-			<ui:insert name="metadata" />
-		</f:metadata>
-
 		<!-- header -->
 		<ui:include src="header.xhtml" />
 

Modified: empire-db/trunk/empire-db-jsf2/pom.xml
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/pom.xml?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/pom.xml (original)
+++ empire-db/trunk/empire-db-jsf2/pom.xml Wed Mar 20 17:36:23 2013
@@ -44,11 +44,21 @@
 		<dependency>
 			<groupId>com.sun.faces</groupId>
 			<artifactId>jsf-api</artifactId>
+			<scope>provided</scope>
 		</dependency>
+		<!-- Mojarra --> 
 		<dependency>
 			<groupId>com.sun.faces</groupId>
 			<artifactId>jsf-impl</artifactId>
+			<scope>provided</scope>
+		</dependency>
+		<!-- MyFaces --> 
+		<dependency>
+			<groupId>org.apache.myfaces.core</groupId>
+			<artifactId>myfaces-impl</artifactId>
+			<scope>provided</scope>
 		</dependency>
+		<!-- EL --> 
 		<dependency>
 			<groupId>org.apache.tomcat</groupId>
 			<artifactId>el-api</artifactId>

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplication.java
Wed Mar 20 17:36:23 2013
@@ -20,18 +20,43 @@ package org.apache.empire.jsf2.app;
 
 import java.sql.Connection;
 import java.sql.SQLException;
+import java.util.Collection;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.Map;
 import java.util.ResourceBundle;
 
+import javax.el.ELContextListener;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import javax.el.ExpressionFactory;
+import javax.el.ValueExpression;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
 import javax.faces.application.FacesMessage;
 import javax.faces.application.FacesMessage.Severity;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.ProjectStage;
+import javax.faces.application.Resource;
+import javax.faces.application.ResourceHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
 import javax.faces.component.UIViewRoot;
+import javax.faces.component.behavior.Behavior;
 import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.PropertyResolver;
+import javax.faces.el.ReferenceSyntaxException;
+import javax.faces.el.ValueBinding;
+import javax.faces.el.VariableResolver;
+import javax.faces.event.ActionListener;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import javax.faces.validator.Validator;
 import javax.servlet.ServletContext;
 import javax.sql.DataSource;
 
@@ -46,9 +71,10 @@ import org.apache.empire.jsf2.controls.T
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.faces.application.ApplicationImpl;
+// import com.sun.faces.application.ApplicationImpl;
 
-public abstract class FacesApplication extends ApplicationImpl
+@SuppressWarnings("deprecation")
+public abstract class FacesApplication extends Application
 {
     private static final Logger log                   = LoggerFactory.getLogger(FacesApplication.class);
 
@@ -59,20 +85,25 @@ public abstract class FacesApplication e
     protected TextResolver[]    textResolvers         = null;
 
     private String              webRoot               = null;
-
-    protected FacesApplication(AppStartupListener startupListener)
-    { // subscribe
-        subscribeToEvent(javax.faces.event.PostConstructApplicationEvent.class, startupListener);
-    }
+    
+    private Application			applImpl 			  = null;
+    
+    private FacesImplementation 	facesImpl			  = null;
 
     protected FacesApplication()
-    { // subscribe
-        this(new AppStartupListener());
+    { 	// subscribe
+    	log.info("FacesApplication {0} created", getClass().getName());
+    }
+    
+    public void setImplementation(FacesImplementation facesImpl, Application applImpl) 
+    {
+    	this.facesImpl = facesImpl;
+    	this.applImpl  = applImpl; 
     }
 
-    protected abstract DataSource getAppDataSource(DBDatabase db);
+	protected abstract DataSource getAppDataSource(DBDatabase db);
 
-    protected abstract void init(ServletContext fc);
+    protected abstract void init(ServletContext servletContext);
 
     protected void initComplete(ServletContext servletContext)
     {
@@ -105,6 +136,15 @@ public abstract class FacesApplication e
     }
 
     /**
+     * return the interface for Implementation specific features 
+     * that are specific for Mojarra or MyFaces
+     */
+    public FacesImplementation getFacesImplemenation() 
+    {
+		return facesImpl;
+	}
+    
+    /**
      * returns the web context path as returned from ServletContext.getContextPath()
      */
     public String getWebRoot()
@@ -325,14 +365,14 @@ public abstract class FacesApplication e
      *      String)
      */
     @Override
-    public ResourceBundle getResourceBundle(FacesContext fc, String var)
+    public ResourceBundle getResourceBundle(final FacesContext fc, final String var)
     {
         if (var.equals("msg"))
         {
             TextResolver resolver = getTextResolver(fc);
             return resolver.getResourceBundle();
         }
-        return null;
+        return applImpl.getResourceBundle(fc, var);
     }
 
     /**
@@ -461,5 +501,387 @@ public abstract class FacesApplication e
     {
         releaseConnection(fc, db, !hasError(fc));
     }
+    
+    /************************************************************/
+
+	@Override
+	public void addBehavior(String behaviorId, String behaviorClass) {
+		// Forward to implementation
+		applImpl.addBehavior(behaviorId, behaviorClass);
+	}
+
+	@Override
+	public void addComponent(String componentType, String componentClass) {
+		// Forward to implementation
+		applImpl.addComponent(componentType, componentClass);
+	}
+
+	@Override
+	public void addConverter(Class<?> targetClass, String converterClass) {
+		// Forward to implementation
+		applImpl.addConverter(targetClass, converterClass);
+	}
+
+	@Override
+	public void addConverter(String converterId, String converterClass) {
+		// Forward to implementation
+		applImpl.addConverter(converterId, converterClass);
+	}
+
+	@Override
+	public void addDefaultValidatorId(String validatorId) {
+		// Forward to implementation
+		applImpl.addDefaultValidatorId(validatorId);
+	}
+
+	@Override
+	public void addELContextListener(ELContextListener listener) {
+		// Forward to implementation
+		applImpl.addELContextListener(listener);
+	}
+
+	@Override
+	public void addELResolver(ELResolver resolver) {
+		// Forward to implementation
+		applImpl.addELResolver(resolver);
+	}
+
+	@Override
+	public void addValidator(String validatorId, String validatorClass) {
+		// Forward to implementation
+		applImpl.addValidator(validatorId, validatorClass);
+	}
+
+	@Override
+	public Behavior createBehavior(String behaviorId) throws FacesException {
+		// Forward to implementation
+		return applImpl.createBehavior(behaviorId);
+	}
+
+	@Override
+	public UIComponent createComponent(FacesContext context,
+			Resource componentResource) {
+		// Forward to implementation
+		return applImpl.createComponent(context, componentResource);
+	}
+
+	@Override
+	public UIComponent createComponent(FacesContext context,
+			String componentType, String rendererType) {
+		// Forward to implementation
+		return applImpl.createComponent(context, componentType, rendererType);
+	}
+
+	@Override
+	public UIComponent createComponent(String componentType)
+			throws FacesException {
+		// Forward to implementation
+		return applImpl.createComponent(componentType);
+	}
+
+	@Override
+	public UIComponent createComponent(ValueBinding componentBinding,
+			FacesContext context, String componentType) throws FacesException {
+		// Forward to implementation
+		return applImpl.createComponent(componentBinding, context, componentType);
+	}
+
+	@Override
+	public UIComponent createComponent(ValueExpression componentExpression,
+			FacesContext context, String componentType) throws FacesException {
+		// Forward to implementation
+		return applImpl.createComponent(componentExpression, context, componentType);
+	}
+
+	@Override
+	public UIComponent createComponent(ValueExpression componentExpression,
+			FacesContext context, String componentType, String rendererType) {
+		// Forward to implementation
+		return applImpl.createComponent(componentExpression, context, componentType, rendererType);
+	}
+
+	@Override
+	public Converter createConverter(Class<?> targetClass) {
+		// Forward to implementation
+		return applImpl.createConverter(targetClass);
+	}
+
+	@Override
+	public Converter createConverter(String converterId) {
+		// Forward to implementation
+		return applImpl.createConverter(converterId);
+	}
+
+	@Override
+	public MethodBinding createMethodBinding(String ref, Class<?>[] params)
+			throws ReferenceSyntaxException {
+		// Forward to implementation
+		return applImpl.createMethodBinding(ref, params);
+	}
+
+	@Override
+	public Validator createValidator(String validatorId) throws FacesException {
+		// Forward to implementation
+		return applImpl.createValidator(validatorId);
+	}
+
+	@Override
+	public ValueBinding createValueBinding(String ref)
+			throws ReferenceSyntaxException {
+		// Forward to implementation
+		return applImpl.createValueBinding(ref);
+	}
+
+	@Override
+	public <T> T evaluateExpressionGet(FacesContext context, String expression,
+			Class<? extends T> expectedType) throws ELException {
+		// Forward to implementation
+		return applImpl.evaluateExpressionGet(context, expression, expectedType);
+	}
+
+	@Override
+	public ActionListener getActionListener() {
+		// Forward to implementation
+		return applImpl.getActionListener();
+	}
+
+	@Override
+	public Iterator<String> getBehaviorIds() {
+		// Forward to implementation
+		return applImpl.getBehaviorIds();
+	}
+
+	@Override
+	public Iterator<String> getComponentTypes() {
+		// Forward to implementation
+		return applImpl.getComponentTypes();
+	}
+
+	@Override
+	public Iterator<String> getConverterIds() {
+		// Forward to implementation
+		return applImpl.getConverterIds();
+	}
+
+	@Override
+	public Iterator<Class<?>> getConverterTypes() {
+		// Forward to implementation
+		return applImpl.getConverterTypes();
+	}
+
+	@Override
+	public Locale getDefaultLocale() {
+		// Forward to implementation
+		return applImpl.getDefaultLocale();
+	}
+
+	@Override
+	public String getDefaultRenderKitId() {
+		// Forward to implementation
+		return applImpl.getDefaultRenderKitId();
+	}
+
+	@Override
+	public Map<String, String> getDefaultValidatorInfo() {
+		// Forward to implementation
+		return applImpl.getDefaultValidatorInfo();
+	}
+
+	@Override
+	public ELContextListener[] getELContextListeners() {
+		// Forward to implementation
+		return applImpl.getELContextListeners();
+	}
+
+	@Override
+	public ELResolver getELResolver() {
+		// Forward to implementation
+		return applImpl.getELResolver();
+	}
+
+	@Override
+	public ExpressionFactory getExpressionFactory() {
+		// Forward to implementation
+		return applImpl.getExpressionFactory();
+	}
+
+	@Override
+	public String getMessageBundle() {
+		// Forward to implementation
+		return applImpl.getMessageBundle();
+	}
+
+	@Override
+	public NavigationHandler getNavigationHandler() {
+		// Forward to implementation
+		return applImpl.getNavigationHandler();
+	}
+
+	@Override
+	public ProjectStage getProjectStage() {
+		// Forward to implementation
+		return applImpl.getProjectStage();
+	}
+
+	@Override
+	public PropertyResolver getPropertyResolver() {
+		// Forward to implementation
+		return applImpl.getPropertyResolver();
+	}
+
+	@Override
+	public ResourceHandler getResourceHandler() {
+		// Forward to implementation
+		return applImpl.getResourceHandler();
+	}
+
+	@Override
+	public StateManager getStateManager() {
+		// Forward to implementation
+		return applImpl.getStateManager();
+	}
+
+	@Override
+	public Iterator<Locale> getSupportedLocales() {
+		// Forward to implementation
+		return applImpl.getSupportedLocales();
+	}
+
+	@Override
+	public Iterator<String> getValidatorIds() {
+		// Forward to implementation
+		return applImpl.getValidatorIds();
+	}
+
+	@Override
+	public VariableResolver getVariableResolver() {
+		// Forward to implementation
+		return applImpl.getVariableResolver();
+	}
+
+	@Override
+	public ViewHandler getViewHandler() {
+		// Forward to implementation
+		return applImpl.getViewHandler();
+	}
+
+	@Override
+	public void publishEvent(FacesContext facesContext,
+			Class<? extends SystemEvent> systemEventClass,
+			Class<?> sourceBaseType, Object source) {
+		// Forward to implementation
+		applImpl.publishEvent(facesContext, systemEventClass, sourceBaseType, source);
+	}
+
+	@Override
+	public void publishEvent(FacesContext facesContext,
+			Class<? extends SystemEvent> systemEventClass, Object source) {
+		// Forward to implementation
+		applImpl.publishEvent(facesContext, systemEventClass, source);
+	}
+
+	@Override
+	public void removeELContextListener(ELContextListener listener) {
+		// Forward to implementation
+		applImpl.removeELContextListener(listener);
+	}
+
+	@Override
+	public void setActionListener(ActionListener listener) {
+		// Forward to implementation
+		applImpl.setActionListener(listener);
+	}
+
+	@Override
+	public void setDefaultLocale(Locale locale) {
+		// Forward to implementation
+		applImpl.setDefaultLocale(locale);
+	}
+
+	@Override
+	public void setDefaultRenderKitId(String renderKitId) {
+		// Forward to implementation
+		applImpl.setDefaultRenderKitId(renderKitId);
+	}
+
+	@Override
+	public void setMessageBundle(String bundle) {
+		// Forward to implementation
+		applImpl.setMessageBundle(bundle);
+	}
+
+	@Override
+	public void setNavigationHandler(NavigationHandler handler) {
+		// Forward to implementation
+		applImpl.setNavigationHandler(handler);
+	}
+
+	@Override
+	public void setPropertyResolver(PropertyResolver resolver) {
+		// Forward to implementation
+		applImpl.setPropertyResolver(resolver);
+	}
+
+	@Override
+	public void setResourceHandler(ResourceHandler resourceHandler) {
+		// Forward to implementation
+		applImpl.setResourceHandler(resourceHandler);
+	}
+
+	@Override
+	public void setStateManager(StateManager manager) {
+		// Forward to implementation
+		applImpl.setStateManager(manager);
+	}
+
+	@Override
+	public void setSupportedLocales(Collection<Locale> locales) {
+		// Forward to implementation
+		applImpl.setSupportedLocales(locales);
+	}
+
+	@Override
+	public void setVariableResolver(VariableResolver resolver) {
+		// Forward to implementation
+		applImpl.setVariableResolver(resolver);
+	}
+
+	@Override
+	public void setViewHandler(ViewHandler handler) {
+		// Forward to implementation
+		applImpl.setViewHandler(handler);
+	}
+
+	@Override
+	public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass,
+			Class<?> sourceClass, SystemEventListener listener) {
+		// Forward to implementation
+		applImpl.subscribeToEvent(systemEventClass, sourceClass, listener);
+	}
+
+	@Override
+	public void subscribeToEvent(Class<? extends SystemEvent> systemEventClass,
+			SystemEventListener listener) {
+		// Forward to implementation
+		applImpl.subscribeToEvent(systemEventClass, listener);
+	}
+
+	@Override
+	public void unsubscribeFromEvent(
+			Class<? extends SystemEvent> systemEventClass,
+			Class<?> sourceClass, SystemEventListener listener) {
+		// Forward to implementation
+		applImpl.unsubscribeFromEvent(systemEventClass, sourceClass, listener);
+	}
+
+	@Override
+	public void unsubscribeFromEvent(
+			Class<? extends SystemEvent> systemEventClass,
+			SystemEventListener listener) {
+		// Forward to implementation
+		applImpl.unsubscribeFromEvent(systemEventClass, listener);
+	}
 
+    /************************************************************/
+    
 }

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplicationFactory.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplicationFactory.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplicationFactory.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesApplicationFactory.java
Wed Mar 20 17:36:23 2013
@@ -18,31 +18,67 @@
  */
 package org.apache.empire.jsf2.app;
 
-import java.util.Map;
-
 import javax.faces.application.Application;
 import javax.faces.application.ApplicationFactory;
-import javax.faces.context.FacesContext;
 
 import org.apache.empire.exceptions.InternalException;
 import org.apache.empire.exceptions.InvalidArgumentException;
 import org.apache.empire.exceptions.ItemExistsException;
+import org.apache.empire.jsf2.app.impl.MojarraImplementation;
+import org.apache.empire.jsf2.app.impl.MyFacesImplementation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.faces.application.InjectionApplicationFactory;
-
 public abstract class FacesApplicationFactory extends ApplicationFactory
 {
     private static final Logger  log = LoggerFactory.getLogger(FacesApplicationFactory.class);
+    
+    private final Class<? extends FacesApplication> applicationClass;
 
-    private Class<? extends FacesApplication> applicationClass;
+    private final FacesImplementation facesImplementation;
+
+    private final AppStartupListener startupListener;
+    
+    private volatile FacesApplication application;
     
-    private volatile Application application;
+	private static FacesImplementation detectFacesImplementation()
+	{
+		// Test for Sun Mojarra
+		try {
+			Class.forName("com.sun.faces.application.ApplicationFactoryImpl");
+			return new MojarraImplementation();
+		} catch (ClassNotFoundException e) {
+			// It's not Mojarra
+		}
+		// Test for Apache MyFaces
+		try {
+			Class.forName("org.apache.myfaces.application.ApplicationFactoryImpl");
+			return new MyFacesImplementation();
+		} catch (ClassNotFoundException e) {
+			// It's not MyFaces
+		}
+		// Not found
+		throw new UnsupportedOperationException(); 
+	}
+    
+    protected FacesApplicationFactory(Class<? extends FacesApplication> applicationClass,
FacesImplementation facesImplementation, AppStartupListener startupListener)
+    {
+    	// FacesImplementation
+    	if (facesImplementation==null)
+    		facesImplementation= detectFacesImplementation();
+
+    	// FacesImplementation
+    	this.facesImplementation = facesImplementation;
+        this.applicationClass    = applicationClass;
+        this.startupListener     = startupListener;
+
+        // log
+        log.info("FacesApplicationFactory created for {0} using Implemenation {1}.", applicationClass,
facesImplementation.getClass().getName());
+    }
     
     protected FacesApplicationFactory(Class<? extends FacesApplication> applicationClass)
     {
-        this.applicationClass  = applicationClass;
+    	this(applicationClass, null, new AppStartupListener());
     }
 
     @Override
@@ -50,8 +86,12 @@ public abstract class FacesApplicationFa
     {
         if (application == null)
         {   try
-            {   // Create Application
+            {	// Create FacesApplication
                 application = applicationClass.newInstance();
+        		// init
+        		facesImplementation.initApplication(application);
+                // subscribe
+                application.subscribeToEvent(javax.faces.event.PostConstructApplicationEvent.class,
startupListener);
             }
             catch (InstantiationException e)
             {
@@ -61,9 +101,6 @@ public abstract class FacesApplicationFa
             {
                 throw new InternalException(e);
             }
-            // InjectionApplicationFactory.setApplicationInstance(application);
-            Map<String, Object> appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
-            appMap.put(InjectionApplicationFactory.class.getName(), application);
             // log
             log.info("Fin2Application Application instance created");
         }
@@ -77,6 +114,6 @@ public abstract class FacesApplicationFa
             throw new ItemExistsException(this.application);
         if (!(application instanceof FacesApplication))
             throw new InvalidArgumentException("application", application);
-        this.application = application;
+        this.application = (FacesApplication)application;
     }
 }

Added: 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=1458973&view=auto
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
(added)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
Wed Mar 20 17:36:23 2013
@@ -0,0 +1,70 @@
+package org.apache.empire.jsf2.app;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+
+public interface FacesImplementation 
+{
+	/**
+	 * Init application
+	 * @param application the FacesApplication instance
+	 *	
+	 *	Implementation example:
+	 *	--------------------------- 
+	 *	ApplicationFactoryImpl applFactoryImpl = new ApplicationFactoryImpl();
+     *	// set implementation
+     *	application.setImplementation(this, applFactoryImpl.getApplication());
+     *	applFactoryImpl.setApplication(application);
+	 */
+	void initApplication(FacesApplication application);
+
+	/**
+	 *	Registers a managed bean	
+	 *
+	 *	Implementation for Mojarra:
+	 *	--------------------------- 
+	 *	FacesContext fc = FacesContext.getCurrentInstance();
+	 * 	BeanManager  bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager();
+	 * 	// check
+     * 	if (bm.getRegisteredBeans().containsKey(beanName))
+     * 	    throw new ItemExistsException(beanName);
+     * 	// register now
+     * 	ManagedBeanInfo mbi = new ManagedBeanInfo(beanName, beanClass, "view", null, null,
null, null);
+     * 	bm.register(mbi);
+     *  
+     *  
+	 *	Implementation for MyFaces:
+	 *	--------------------------- 
+	 *	FacesContext  fc = FacesContext.getCurrentInstance();
+	 *	RuntimeConfig rc = RuntimeConfig.getCurrentInstance(fc.getExternalContext());
+	 *	// check
+     *	if (rc.getManagedBeans().containsKey(beanName))
+     *	    throw new ItemExistsException(beanName);
+     *	// register now
+     *	ManagedBean mbi = new ManagedBean(); 
+     *	mbi.setName(beanName);
+     *	mbi.setBeanClass(beanClass);
+     *	mbi.setScope(scope);
+     *	rc.addManagedBean(beanName, mbi);
+     *  
+	 */
+	void registerManagedBean(String beanName, String beanClass, String scope);
+	
+	/**
+	 *	Return the parentComponent for a given ValueExpression.
+	 *
+	 *	Implementation for Mojarra:
+	 *	--------------------------- 
+	 *  if (ve instanceof ContextualCompositeValueExpression)
+     *  {
+     *      FacesContext ctx = FacesContext.getCurrentInstance();
+     *      ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve;
+     *      CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx);
+     *      UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation());
+     *      // set Parent
+     *      return cc;
+     *  }
+	 */
+	UIComponent getValueParentComponent(ValueExpression ve);
+	
+}

Propchange: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/FacesImplementation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1458973&view=auto
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
(added)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
Wed Mar 20 17:36:23 2013
@@ -0,0 +1,65 @@
+package org.apache.empire.jsf2.app.impl;
+
+import java.util.Map;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.empire.exceptions.ItemExistsException;
+import org.apache.empire.jsf2.app.FacesApplication;
+import org.apache.empire.jsf2.app.FacesImplementation;
+
+import com.sun.faces.application.ApplicationAssociate;
+import com.sun.faces.application.ApplicationFactoryImpl;
+import com.sun.faces.application.InjectionApplicationFactory;
+import com.sun.faces.component.CompositeComponentStackManager;
+import com.sun.faces.facelets.el.ContextualCompositeValueExpression;
+import com.sun.faces.mgbean.BeanManager;
+import com.sun.faces.mgbean.ManagedBeanInfo;
+
+public class MojarraImplementation implements FacesImplementation 
+{
+
+	@Override
+	public void initApplication(FacesApplication application)
+	{
+		ApplicationFactoryImpl applFactoryImpl = new ApplicationFactoryImpl();
+        // set impl
+        application.setImplementation(this, applFactoryImpl.getApplication());
+        // Application Map 
+        Map<String, Object> appMap = FacesContext.getCurrentInstance().getExternalContext().getApplicationMap();
+        appMap.put(InjectionApplicationFactory.class.getName(), application);
+	}
+
+	@Override
+	public void registerManagedBean(String beanName, String beanClass, String scope) 
+	{
+		FacesContext fc = FacesContext.getCurrentInstance();
+		BeanManager  bm = ApplicationAssociate.getInstance(fc.getExternalContext()).getBeanManager();
+		// check
+        if (bm.getRegisteredBeans().containsKey(beanName))
+        {
+            throw new ItemExistsException(beanName);
+        }
+        // register now
+        ManagedBeanInfo mbi = new ManagedBeanInfo(beanName, beanClass, "view", null, null,
null, null);
+        bm.register(mbi);
+	}
+
+	@Override
+	public UIComponent getValueParentComponent(ValueExpression ve) 
+	{
+        if (ve instanceof ContextualCompositeValueExpression)
+        {
+            FacesContext ctx = FacesContext.getCurrentInstance();
+            ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve;
+            CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx);
+            UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation());
+            // set Parent
+            return cc;
+        }
+        return null;
+	}
+
+}

Propchange: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MojarraImplementation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Added: 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=1458973&view=auto
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
(added)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
Wed Mar 20 17:36:23 2013
@@ -0,0 +1,51 @@
+package org.apache.empire.jsf2.app.impl;
+
+import javax.el.ValueExpression;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+
+import org.apache.empire.exceptions.ItemExistsException;
+import org.apache.empire.jsf2.app.FacesApplication;
+import org.apache.empire.jsf2.app.FacesImplementation;
+import org.apache.myfaces.application.ApplicationFactoryImpl;
+import org.apache.myfaces.config.RuntimeConfig;
+import org.apache.myfaces.config.impl.digester.elements.ManagedBean;
+
+public class MyFacesImplementation implements FacesImplementation 
+{
+	
+	@Override
+	public void initApplication(FacesApplication application)
+	{
+		ApplicationFactoryImpl applFactoryImpl = new ApplicationFactoryImpl();
+        // set impl
+        application.setImplementation(this, applFactoryImpl.getApplication());
+        applFactoryImpl.setApplication(application);
+	}
+
+	@Override
+	public void registerManagedBean(String beanName, String beanClass, String scope) {
+		
+		FacesContext  fc = FacesContext.getCurrentInstance();
+		RuntimeConfig rc = RuntimeConfig.getCurrentInstance(fc.getExternalContext());
+		// check
+        if (rc.getManagedBeans().containsKey(beanName))
+        {
+            throw new ItemExistsException(beanName);
+        }
+        // register now
+        ManagedBean mbi = new ManagedBean(); 
+        mbi.setName(beanName);
+        mbi.setBeanClass(beanClass);
+        mbi.setScope(scope);
+        rc.addManagedBean(beanName, mbi);
+	}
+
+	@Override
+	public UIComponent getValueParentComponent(ValueExpression ve)
+	{
+		/* No implmentation for MyFaces currently available */
+		return null;
+	}
+
+}

Propchange: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/app/impl/MyFacesImplementation.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/pages/PageDefinitions.java
Wed Mar 20 17:36:23 2013
@@ -24,12 +24,10 @@ import java.util.LinkedHashMap;
 import org.apache.empire.commons.StringUtils;
 import org.apache.empire.exceptions.ItemExistsException;
 import org.apache.empire.exceptions.MiscellaneousErrorException;
+import org.apache.empire.jsf2.app.FacesImplementation;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.faces.mgbean.BeanManager;
-import com.sun.faces.mgbean.ManagedBeanInfo;
-
 
 public abstract class PageDefinitions implements Serializable
 {
@@ -70,29 +68,16 @@ public abstract class PageDefinitions im
      * Register page beans with the BeanManager
      * @param bm
      */
-    public void registerPageBeans(BeanManager bm)
+    public void registerPageBeans(FacesImplementation facesImpl)
     {
         for (PageDefinition v : pageMap.values())
         {
             String beanName  = v.getPageBeanName();
             String beanClass = v.getPageBeanClass().getName();
-            // check
-            if (bm.getRegisteredBeans().containsKey(beanName))
-            {
-                throw new ItemExistsException(beanName);
-            }
+            // log
             log.info("Registering managed bean '{}' of class '{}' for page '{}'.", new Object[]
{ beanName, beanClass, v.getPath() });
-            /*
-            ManagedBeanInfo(String name,
-                            String className,
-                            String beanScope,
-                            ManagedBeanInfo.MapEntry mapEntry,
-                            ManagedBeanInfo.ListEntry listEntry,
-                            List<ManagedBeanInfo.ManagedProperty> managedProperties,
-                            Map<String,String> descriptions) {
-            */
-            ManagedBeanInfo mbi = new ManagedBeanInfo(beanName, beanClass, "view", null,
null, null, null);
-            bm.register(mbi);
+            // register
+            facesImpl.registerManagedBean(beanName, beanClass, "view");
         }
     }
     

Modified: empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
URL: http://svn.apache.org/viewvc/empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
(original)
+++ empire-db/trunk/empire-db-jsf2/src/main/java/org/apache/empire/jsf2/utils/TagEncodingHelper.java
Wed Mar 20 17:36:23 2013
@@ -24,6 +24,7 @@ import java.util.Iterator;
 import java.util.Locale;
 
 import javax.el.ValueExpression;
+import javax.faces.FacesWrapper;
 import javax.faces.application.FacesMessage;
 import javax.faces.component.NamingContainer;
 import javax.faces.component.UIComponent;
@@ -71,10 +72,6 @@ import org.apache.empire.jsf2.controls.T
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import com.sun.faces.component.CompositeComponentStackManager;
-import com.sun.faces.facelets.el.ContextualCompositeValueExpression;
-import com.sun.faces.facelets.el.TagValueExpression;
-
 public class TagEncodingHelper implements NamingContainer
 {
     /**
@@ -917,17 +914,13 @@ public class TagEncodingHelper implement
         while (expr.startsWith(CC_ATTR_EXPR))
         {
             // Unwrap
-            if (ve instanceof TagValueExpression)
-                ve = ((TagValueExpression)ve).getWrapped();
+            if (ve instanceof FacesWrapper<?>)
+                ve = ((FacesWrapper<ValueExpression>)ve).getWrapped();
             // find parent
-            if (ve instanceof ContextualCompositeValueExpression)
-            {
-                FacesContext ctx = FacesContext.getCurrentInstance();
-                ContextualCompositeValueExpression ccve = (ContextualCompositeValueExpression)ve;
-                CompositeComponentStackManager manager = CompositeComponentStackManager.getManager(ctx);
-                UIComponent cc = manager.findCompositeComponentUsingLocation(ctx, ccve.getLocation());
-                // set Parent
-                parent = cc;
+            UIComponent valueParent = FacesUtils.getFacesApplication().getFacesImplemenation().getValueParentComponent(ve);
+            if (valueParent!=null)
+            {	// use the value parent
+            	parent = valueParent;
             }
             else
             {   // find parent

Modified: empire-db/trunk/pom.xml
URL: http://svn.apache.org/viewvc/empire-db/trunk/pom.xml?rev=1458973&r1=1458972&r2=1458973&view=diff
==============================================================================
--- empire-db/trunk/pom.xml (original)
+++ empire-db/trunk/pom.xml Wed Mar 20 17:36:23 2013
@@ -306,7 +306,7 @@
 			    <artifactId>javassist</artifactId>
 			    <version>3.8.0.GA</version>
 			</dependency>
-			<!-- jsf2 -->			
+			<!-- Sun Mojarra -->			
 			<dependency>
 				<groupId>com.sun.faces</groupId>
 				<artifactId>jsf-api</artifactId>
@@ -317,6 +317,17 @@
 				<artifactId>jsf-impl</artifactId>
 				<version>2.1.6</version>
 			</dependency>
+			<!-- Apache MyFaces -->
+			<dependency>
+				<groupId>org.apache.myfaces.core</groupId>
+				<artifactId>myfaces-api</artifactId>
+				<version>2.1.10</version>
+			</dependency>
+			<dependency>
+				<groupId>org.apache.myfaces.core</groupId>
+				<artifactId>myfaces-impl</artifactId>
+				<version>2.1.10</version>
+			</dependency>
 	        <!-- Misc -->
 			<dependency>
 				<groupId>junit</groupId>



Mime
View raw message