Author: nbelaevski
Date: 2010-12-23 10:55:58 -0500 (Thu, 23 Dec 2010)
New Revision: 20776
Removed:
trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java
Modified:
trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java
Log:
https://issues.jboss.org/browse/RF-2968
Modified: trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2010-12-23
15:45:04 UTC (rev 20775)
+++ trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -25,7 +25,7 @@
import java.util.Date;
-import javax.faces.el.MethodBinding;
+import javax.el.MethodExpression;
/**
* @author shura (latest modification by $Author: alexsmirnov $)
@@ -113,14 +113,20 @@
public abstract void setValue(Object newvalue);
/**
- * Get El binding to method in user bean to send resource. Method will called with
two parameters - restored data object and servlet output stream.
- * @return
+ * Get MethodExpression to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @return MethodExpression
*/
- public abstract MethodBinding getCreateContent();
+ public abstract MethodExpression getCreateContent();
/**
- * Set El binding to method in user bean to send resource. Method will called with
two parameters - restored data object and servlet output stream.
- * @param newvalue
+ * Set MethodExpression to method in user bean to send resource. Method will
+ * called with two parameters - restored data object and servlet output
+ * stream.
+ *
+ * @param newvalue - new MethodExpression value
*/
- public abstract void setCreateContent(MethodBinding newvalue);
+ public abstract void setCreateContent(MethodExpression newvalue);
}
Deleted: trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java
===================================================================
--- trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java 2010-12-23
15:45:04 UTC (rev 20775)
+++ trunk/core/api/src/main/java/org/ajax4jsf/resource/ResourceComponent2.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -1,54 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-
-
-package org.ajax4jsf.resource;
-
-import javax.el.MethodExpression;
-
-/**
- * Interface for the ResourceComponent introduced after refactoring
- * to support MethodExpression. Old interface is left for the
- * compatibility.
- *
- * @author Vladislav Baranov
- */
-public interface ResourceComponent2 extends ResourceComponent {
-
- /**
- * Get MethodExpression to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @return MethodExpression
- */
- public abstract MethodExpression getCreateContentExpression();
-
- /**
- * Set MethodExpression to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @param newvalue - new MethodExpression value
- */
- public abstract void setCreateContentExpression(MethodExpression newvalue);
-}
Deleted:
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java 2010-12-23
15:45:04 UTC (rev 20775)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodBindingMethodExpressionAdaptor.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -1,100 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-
-/**
- * Maps {@link MethodExpression} to {@link MethodBinding}
- *
- * @author Maksim Kaszynski
- */
-@SuppressWarnings("deprecation")
-public class MethodBindingMethodExpressionAdaptor extends MethodBinding implements
StateHolder {
- private MethodExpression expression;
- private boolean tranzient;
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.MethodBinding#getType(javax.faces.context.FacesContext)
- */
- public MethodBindingMethodExpressionAdaptor() {
-
- // TODO Auto-generated constructor stub
- }
-
- public MethodBindingMethodExpressionAdaptor(MethodExpression expression) {
- super();
- this.expression = expression;
- }
-
- @Override
- public Class<?> getType(FacesContext context) throws MethodNotFoundException {
- try {
- return expression.getMethodInfo(context.getELContext()).getReturnType();
- } catch (javax.el.MethodNotFoundException e) {
- throw new MethodNotFoundException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.el.MethodBinding#invoke(javax.faces.context.FacesContext,
java.lang.Object[])
- */
- @Override
- public Object invoke(FacesContext context, Object[] params) throws
EvaluationException, MethodNotFoundException {
- try {
- return expression.invoke(context.getELContext(), params);
- } catch (javax.el.MethodNotFoundException e) {
- throw new MethodNotFoundException(e);
- } catch (ELException e) {
- throw new EvaluationException(e);
- }
- }
-
- public boolean isTransient() {
- return tranzient;
- }
-
- public void restoreState(FacesContext context, Object state) {
- expression = (MethodExpression) state;
- }
-
- public Object saveState(FacesContext context) {
- return expression;
- }
-
- public void setTransient(boolean newTransientValue) {
- tranzient = newTransientValue;
- }
-
- @Override
- public String getExpressionString() {
- return expression.getExpressionString();
- }
-}
Deleted:
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java
===================================================================
---
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java 2010-12-23
15:45:04 UTC (rev 20775)
+++
trunk/ui/common/ui/src/main/java/org/richfaces/component/MethodExpressionMethodBindingAdaptor.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -1,202 +0,0 @@
-/**
- * License Agreement.
- *
- * Rich Faces - Natural Ajax for Java Server Faces (JSF)
- *
- * Copyright (C) 2007 Exadel, Inc.
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License version 2.1 as published by the Free Software Foundation.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- */
-
-package org.richfaces.component;
-
-import javax.el.ELContext;
-import javax.el.ELException;
-import javax.el.MethodExpression;
-import javax.el.MethodInfo;
-import javax.faces.FacesException;
-import javax.faces.component.StateHolder;
-import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
-import javax.faces.el.MethodNotFoundException;
-import java.io.Serializable;
-
-/**
- * @author Maksim Kaszynski
- */
-@SuppressWarnings("deprecation")
-public class MethodExpressionMethodBindingAdaptor extends MethodExpression implements
StateHolder, Serializable {
- private static final long serialVersionUID = 1L;
- private MethodBinding binding;
- private boolean tranzient;
-
- public MethodExpressionMethodBindingAdaptor() {
- }
-
- public MethodExpressionMethodBindingAdaptor(MethodBinding binding) {
- this.binding = binding;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.MethodExpression#getMethodInfo(javax.el.ELContext)
- */
- @Override
- public MethodInfo getMethodInfo(ELContext context) {
- FacesContext context2 = (FacesContext) context.getContext(FacesContext.class);
-
- try {
- return new MethodInfo(null, binding.getType(context2), null);
- } catch (MethodNotFoundException e) {
- throw new javax.el.MethodNotFoundException(e);
- } catch (EvaluationException e) {
- throw new ELException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.MethodExpression#invoke(javax.el.ELContext, java.lang.Object[])
- */
- @Override
- public Object invoke(ELContext context, Object[] params) {
- FacesContext context2 = (FacesContext) context.getContext(FacesContext.class);
-
- try {
- return binding.invoke(context2, params);
- } catch (MethodNotFoundException e) {
- throw new javax.el.MethodNotFoundException(e);
- } catch (EvaluationException e) {
- throw new ELException(e);
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.Expression#getExpressionString()
- */
- @Override
- public String getExpressionString() {
- return binding.getExpressionString();
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
-
- result = prime * result + ((binding == null) ? 0 : binding.hashCode());
-
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
-
- if (getClass() != obj.getClass()) {
- return false;
- }
-
- MethodExpressionMethodBindingAdaptor other =
(MethodExpressionMethodBindingAdaptor) obj;
-
- if (binding == null) {
- if (other.binding != null) {
- return false;
- }
- } else if (!binding.equals(other.binding)) {
- return false;
- }
-
- return true;
- }
-
- /*
- * (non-Javadoc)
- * @see javax.el.Expression#isLiteralText()
- */
- @Override
- public boolean isLiteralText() {
- String expr = binding.getExpressionString();
-
- return !(expr.startsWith("#{") &&
expr.endsWith("}"));
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#isTransient()
- */
- public boolean isTransient() {
- return tranzient;
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.component.StateHolder#restoreState(javax.faces.context.FacesContext,
java.lang.Object)
- */
- public void restoreState(FacesContext context, Object state) {
- if (state instanceof MethodBinding) {
- binding = (MethodBinding) state;
- } else {
- Object[] states = (Object[]) state;
- String className = states[0].toString();
- ClassLoader loader = Thread.currentThread().getContextClassLoader();
-
- if (loader == null) {
- loader = this.getClass().getClassLoader();
- }
-
- try {
- Class<?> bindingClass = Class.forName(className, true, loader);
-
- binding = (MethodBinding) bindingClass.newInstance();
- ((StateHolder) binding).restoreState(context, states[1]);
- } catch (Exception e) {
- throw new FacesException(e);
- }
- }
- }
-
- /*
- * (non-Javadoc)
- * @see
javax.faces.component.StateHolder#saveState(javax.faces.context.FacesContext)
- */
- public Object saveState(FacesContext context) {
- if (binding instanceof StateHolder) {
- Object[] state = new Object[2];
-
- state[0] = binding.getClass().getName();
- state[1] = ((StateHolder) binding).saveState(context);
-
- return state;
- } else {
- return binding;
- }
- }
-
- /*
- * (non-Javadoc)
- * @see javax.faces.component.StateHolder#setTransient(boolean)
- */
- public void setTransient(boolean newTransientValue) {
- tranzient = newTransientValue;
- }
-
- public MethodBinding getBinding() {
- return binding;
- }
-}
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-23
15:45:04 UTC (rev 20775)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/component/AbstractMediaOutput.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -23,21 +23,17 @@
package org.richfaces.component;
-import java.io.OutputStream;
import java.util.Date;
-import javax.el.MethodExpression;
import javax.faces.application.Resource;
import javax.faces.application.ResourceHandler;
import javax.faces.component.UIOutput;
-import javax.faces.el.MethodBinding;
-import org.ajax4jsf.resource.ResourceComponent2;
+import org.ajax4jsf.resource.ResourceComponent;
import org.richfaces.cdk.annotations.Attribute;
import org.richfaces.cdk.annotations.EventName;
import org.richfaces.cdk.annotations.JsfComponent;
import org.richfaces.cdk.annotations.JsfRenderer;
-import org.richfaces.cdk.annotations.Signature;
import org.richfaces.cdk.annotations.Tag;
import org.richfaces.cdk.annotations.TagType;
import org.richfaces.resource.MediaOutputResource;
@@ -50,7 +46,7 @@
tag = @Tag(generate = false, handler =
"org.richfaces.view.facelets.html.MediaOutputHandler", type =
TagType.Facelets),
renderer = @JsfRenderer(type = "org.richfaces.MediaOutputRenderer")
)
-public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent2
{
+public abstract class AbstractMediaOutput extends UIOutput implements ResourceComponent
{
public static final String COMPONENT_TYPE = "org.richfaces.MediaOutput";
@@ -70,53 +66,6 @@
@Attribute
public abstract String getElement();
- /**
- * Get EL binding to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @return MethodBinding to createContent
- */
- @Attribute(signature = @Signature(parameters = {OutputStream.class, Object.class}))
- public MethodBinding getCreateContent() {
- MethodBinding result = null;
- MethodExpression me = getCreateContentExpression();
-
- if (me != null) {
-
- // if the MethodExpression is an instance of our private
- // wrapper class.
- if (me instanceof MethodExpressionMethodBindingAdaptor) {
- result = ((MethodExpressionMethodBindingAdaptor) me).getBinding();
- } else {
-
- // otherwise, this is a real MethodExpression. Wrap it
- // in a MethodBinding.
- result = new MethodBindingMethodExpressionAdaptor(me);
- }
- }
-
- return result;
- }
-
- /**
- * Set EL binding to method in user bean to send resource. Method will
- * called with two parameters - restored data object and servlet output
- * stream.
- *
- * @param newvalue - new value of createContent method binding
- */
- public void setCreateContent(MethodBinding newvalue) {
- MethodExpressionMethodBindingAdaptor adapter;
-
- if (newvalue != null) {
- adapter = new MethodExpressionMethodBindingAdaptor(newvalue);
- setCreateContentExpression(adapter);
- } else {
- setCreateContentExpression(null);
- }
- }
-
public Resource getResource() {
ResourceHandler resourceHandler =
getFacesContext().getApplication().getResourceHandler();
return resourceHandler.createResource(MediaOutputResource.class.getName());
@@ -152,8 +101,6 @@
@Attribute
public abstract String getCoords();
- public abstract MethodExpression getCreateContentExpression();
-
@Attribute
public abstract String getDeclare();
Modified: trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-23
15:45:04 UTC (rev 20775)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/resource/MediaOutputResource.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -105,7 +105,7 @@
this.setCacheable(uiMediaOutput.isCacheable());
this.setContentType(uiMediaOutput.getMimeType());
this.userData = uiMediaOutput.getValue();
- this.contentProducer = uiMediaOutput.getCreateContentExpression();
+ this.contentProducer = uiMediaOutput.getCreateContent();
this.lastModifiedExpression =
uiMediaOutput.getValueExpression("lastModfied");
this.expiresExpression = uiMediaOutput.getValueExpression("expires");
this.timeToLiveExpression =
uiMediaOutput.getValueExpression("timeToLive");
Modified:
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java
===================================================================
---
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java 2010-12-23
15:45:04 UTC (rev 20775)
+++
trunk/ui/core/ui/src/main/java/org/richfaces/view/facelets/html/MediaOutputHandler.java 2010-12-23
15:55:58 UTC (rev 20776)
@@ -22,8 +22,7 @@
package org.richfaces.view.facelets.html;
-import org.richfaces.component.AbstractMediaOutput;
-import org.richfaces.view.facelets.MethodMetadata;
+import java.io.OutputStream;
import javax.faces.view.facelets.ComponentConfig;
import javax.faces.view.facelets.ComponentHandler;
@@ -33,8 +32,10 @@
import javax.faces.view.facelets.Metadata;
import javax.faces.view.facelets.MetadataTarget;
import javax.faces.view.facelets.TagAttribute;
-import java.io.OutputStream;
+import org.richfaces.component.AbstractMediaOutput;
+import org.richfaces.view.facelets.MethodMetadata;
+
/**
* @author shura (latest modification by $Author: alexsmirnov $)
* @version $Revision: 1.1.2.1 $ $Date: 2007/02/01 15:31:22 $
@@ -62,7 +63,7 @@
if ("createContent".equals(name)) {
return new MethodMetadata(attribute, OutputStream.class,
Object.class) {
public void applyMetadata(FaceletContext ctx, Object instance) {
- ((AbstractMediaOutput)
instance).setCreateContentExpression(getMethodExpression(ctx));
+ ((AbstractMediaOutput)
instance).setCreateContent(getMethodExpression(ctx));
}
};
}