You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by we...@apache.org on 2010/04/12 21:43:37 UTC
svn commit: r933379 [11/15] - in /myfaces/extensions/scripting/trunk:
extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/
extscript-core-root/extscript-core-java6/src/main/java/org/apache/myfaces/extensions/scripting/
...
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ApplicationProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,423 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.el.*;
+import javax.faces.FacesException;
+import javax.faces.application.Application;
+import javax.faces.application.NavigationHandler;
+import javax.faces.application.StateManager;
+import javax.faces.application.ViewHandler;
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.convert.Converter;
+import javax.faces.el.*;
+import javax.faces.event.ActionListener;
+import javax.faces.validator.Validator;
+import java.lang.reflect.Proxy;
+import java.util.*;
+
+/**
+ * our decorating application
+ * which should resolve our bean issues within a central
+ * bean processing interceptor
+ * <p/>
+ *
+ * @author Werner Punz
+ */
+@SuppressWarnings({"deprecation", "deprecation"})
+public class ApplicationProxy extends Application implements Decorated {
+
+ volatile Application _delegate;
+
+ public ApplicationProxy(Application delegate) {
+ _delegate = delegate;
+ }
+
+
+ public void addELResolver(ELResolver elResolver) {
+ weaveDelegate();
+
+ //the same goes for the rest of the factory stuff
+ if (!(elResolver instanceof ELResolverProxy))
+ elResolver = new ELResolverProxy(elResolver);
+ _delegate.addELResolver(elResolver);
+ }
+
+ private void weaveDelegate() {
+ if (_delegate != null) {
+ _delegate = (Application) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_APPLICATION);
+ }
+ }
+
+ public ELResolver getELResolver() {
+ weaveDelegate();
+ ELResolver retVal = _delegate.getELResolver();
+ if (!(retVal instanceof ELResolverProxy))
+ retVal = new ELResolverProxy(retVal);
+ return retVal;
+
+ }
+
+ //TOD add a weaving for resource bundles
+
+ public ResourceBundle getResourceBundle(FacesContext facesContext, String s) throws FacesException, NullPointerException {
+ weaveDelegate();
+ return _delegate.getResourceBundle(facesContext, s);
+ }
+
+ public UIComponent createComponent(ValueExpression valueExpression, FacesContext facesContext, String s) throws FacesException, NullPointerException {
+ weaveDelegate();
+ System.out.println("create1");
+ UIComponent component = _delegate.createComponent(valueExpression, facesContext, s);
+
+ /*we are reweaving on the fly because we cannot be sure if
+ * the class is not recycled all the time in the creation
+ * code, in the renderer we do it on method base
+ * due to the fact that our renderers are recycled via
+ * a flyweight pattern
+ *
+ *
+ * Also we cannot proxy here because there is no UIComponent interface
+ * maybe in the long run we can make a decorator here instead
+ * but for now lets try it this way
+ */
+ if (WeavingContext.isDynamic(component.getClass()) && !alreadyWovenInRequest(component.getClass().getName())) {
+ /*once it was tainted we have to recreate all the time*/
+ component = (UIComponent) WeavingContext.getWeaver().reloadScriptingInstance(component, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
+ alreadyWovenInRequest(component.getClass().getName());
+ }
+ return component;
+
+ }
+
+ public ExpressionFactory getExpressionFactory() {
+ weaveDelegate();
+ return _delegate.getExpressionFactory();
+ }
+
+ public void addELContextListener(ELContextListener elContextListener) {
+ weaveDelegate();
+ if (WeavingContext.isDynamic(elContextListener.getClass()))
+ elContextListener = (ELContextListener) WeavingContext.createMethodReloadingProxyFromObject(elContextListener, ELContextListener.class, ScriptingConst.ARTIFACT_TYPE_ELCONTEXTLISTENER);
+ _delegate.addELContextListener(elContextListener);
+ }
+
+ public void removeELContextListener(ELContextListener elContextListener) {
+ weaveDelegate();
+ _delegate.removeELContextListener(elContextListener);
+ }
+
+ public ELContextListener[] getELContextListeners() {
+ weaveDelegate();
+ return _delegate.getELContextListeners();
+ }
+
+ public Object evaluateExpressionGet(FacesContext facesContext, String s, Class aClass) throws ELException {
+ weaveDelegate();
+ //good place for a dynamic reloading check as well
+ Object retVal = _delegate.evaluateExpressionGet(facesContext, s, aClass);
+ if (WeavingContext.isDynamic(retVal.getClass()))
+ retVal = WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
+ return retVal;
+ }
+
+ public ActionListener getActionListener() {
+ weaveDelegate();
+ ActionListener retVal = _delegate.getActionListener();
+ if (WeavingContext.isDynamic(retVal.getClass()))
+ retVal = (ActionListener) WeavingContext.createMethodReloadingProxyFromObject(retVal, ActionListener.class, ScriptingConst.ARTIFACT_TYPE_ACTIONLISTENER);
+ return retVal;
+ }
+
+ public void setActionListener(ActionListener actionListener) {
+ weaveDelegate();
+ if (WeavingContext.isDynamic(actionListener.getClass()))
+ actionListener = (ActionListener) WeavingContext.createMethodReloadingProxyFromObject(actionListener, ActionListener.class, ScriptingConst.ARTIFACT_TYPE_ACTIONLISTENER);
+ _delegate.setActionListener(actionListener);
+ }
+
+ public Locale getDefaultLocale() {
+ weaveDelegate();
+ return _delegate.getDefaultLocale();
+ }
+
+ public void setDefaultLocale(Locale locale) {
+ weaveDelegate();
+ _delegate.setDefaultLocale(locale);
+ }
+
+ public String getDefaultRenderKitId() {
+ weaveDelegate();
+ return _delegate.getDefaultRenderKitId();
+ }
+
+ public void setDefaultRenderKitId(String s) {
+ weaveDelegate();
+ _delegate.setDefaultRenderKitId(s);
+ }
+
+ public String getMessageBundle() {
+ weaveDelegate();
+ return _delegate.getMessageBundle();
+ }
+
+ public void setMessageBundle(String s) {
+ weaveDelegate();
+ _delegate.setMessageBundle(s);
+ }
+
+ public NavigationHandler getNavigationHandler() {
+ weaveDelegate();
+ //defined in the setter to speed things up a little
+ NavigationHandler retVal = _delegate.getNavigationHandler();
+ if (retVal != null && WeavingContext.isDynamic(retVal.getClass()))
+ retVal = new NavigationHandlerProxy(retVal);
+ return retVal;
+ }
+
+ public void setNavigationHandler(NavigationHandler navigationHandler) {
+ weaveDelegate();
+ if (navigationHandler != null && WeavingContext.isDynamic(navigationHandler.getClass()))
+ navigationHandler = new NavigationHandlerProxy(navigationHandler);
+ _delegate.setNavigationHandler(navigationHandler);
+ }
+
+ @SuppressWarnings("deprecation")
+ public PropertyResolver getPropertyResolver() {
+ weaveDelegate();
+ return _delegate.getPropertyResolver();
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setPropertyResolver(PropertyResolver propertyResolver) {
+ weaveDelegate();
+ _delegate.setPropertyResolver(propertyResolver);
+ }
+
+ @SuppressWarnings("deprecation")
+ public VariableResolver getVariableResolver() {
+ weaveDelegate();
+ VariableResolver variableResolver = _delegate.getVariableResolver();
+ if (!(variableResolver instanceof VariableResolverProxy))
+ variableResolver = new VariableResolverProxy(variableResolver);
+ return variableResolver;
+ }
+
+ @SuppressWarnings("deprecation")
+ public void setVariableResolver(VariableResolver variableResolver) {
+ weaveDelegate();
+ if (!(variableResolver instanceof VariableResolverProxy))
+ variableResolver = new VariableResolverProxy(variableResolver);
+
+ _delegate.setVariableResolver(variableResolver);
+ }
+
+ public ViewHandler getViewHandler() {
+ weaveDelegate();
+ ViewHandler handler = _delegate.getViewHandler();
+
+ /*
+ We proxy here to emable dynamic reloading for
+ methods in the long run, as soon as we hit
+ java all our groovy reloading code is lost
+ hence we have to work with proxies here
+ */
+ if (WeavingContext.isDynamic(handler.getClass()))
+ handler = new ViewHandlerProxy(handler);
+ return handler;
+ }
+
+ public void setViewHandler(ViewHandler viewHandler) {
+ weaveDelegate();
+ /*make sure you have the delegates as well in properties*/
+ if (WeavingContext.isDynamic(viewHandler.getClass()))
+ viewHandler = new ViewHandlerProxy(viewHandler);
+
+ _delegate.setViewHandler(viewHandler);
+ }
+
+ public StateManager getStateManager() {
+ weaveDelegate();
+ return _delegate.getStateManager();
+ }
+
+ public void setStateManager(StateManager stateManager) {
+ weaveDelegate();
+ _delegate.setStateManager(stateManager);
+ }
+
+ public void addComponent(String componentType, String componentClass) {
+ weaveDelegate();
+ _delegate.addComponent(componentType, componentClass);
+ }
+
+ public UIComponent createComponent(String s) throws FacesException {
+ weaveDelegate();
+ //the components are generated anew very often
+ //we cannot do an on object weaving here
+ UIComponent component = _delegate.createComponent(s);
+
+ /*we are reweaving on the fly because we cannot be sure if
+ * the class is not recycled all the time in the creation
+ * code, in the renderer we do it on method base
+ * due to the fact that our renderers are recycled via
+ * a flyweight pattern*/
+ return (UIComponent) reloadInstance(component, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
+ }
+
+ @SuppressWarnings("deprecation")
+ public UIComponent createComponent(ValueBinding valueBinding, FacesContext facesContext, String s) throws FacesException {
+ weaveDelegate();
+ UIComponent component = _delegate.createComponent(valueBinding, facesContext, s);
+
+ /*we are reweaving on the fly because we cannot be sure if
+ * the class is not recycled all the time in the creation
+ * code, in the renderer we do it on method base
+ * due to the fact that our renderers are recycled via
+ * a flyweight pattern*/
+ return (UIComponent) reloadInstance(component, ScriptingConst.ARTIFACT_TYPE_COMPONENT);
+ }
+
+ public Iterator<String> getComponentTypes() {
+ weaveDelegate();
+ return _delegate.getComponentTypes();
+ }
+
+ public void addConverter(String s, String s1) {
+ weaveDelegate();
+ _delegate.addConverter(s, s1);
+ }
+
+ public void addConverter(Class aClass, String s) {
+ weaveDelegate();
+ _delegate.addConverter(aClass, s);
+ }
+
+ public Converter createConverter(String s) {
+ weaveDelegate();
+ Converter retVal = _delegate.createConverter(s);
+ /**
+ * since createConverter is called only once
+ * we have to work with method reloading proxies
+ * we cannot use this technique extensively for speed reasons
+ * most of the time it is fine just to work with
+ *
+ * reloading objects at their interception points
+ */
+ if (WeavingContext.isDynamic(retVal.getClass())) {
+ retVal = (Converter) WeavingContext.createMethodReloadingProxyFromObject(retVal, Converter.class, ScriptingConst.ARTIFACT_TYPE_CONVERTER);
+
+ }
+
+ return retVal;
+ }
+
+ public Converter createConverter(Class aClass) {
+ weaveDelegate();
+ Converter retVal = _delegate.createConverter(aClass);
+ if (retVal != null && WeavingContext.isDynamic(retVal.getClass())) {
+ retVal = (Converter) WeavingContext.createMethodReloadingProxyFromObject(retVal, Converter.class, ScriptingConst.ARTIFACT_TYPE_CONVERTER);
+ }
+
+ return retVal;
+ }
+
+ public Iterator<String> getConverterIds() {
+ weaveDelegate();
+ return _delegate.getConverterIds();
+ }
+
+ public Iterator<Class> getConverterTypes() {
+ weaveDelegate();
+ return _delegate.getConverterTypes();
+ }
+
+ @SuppressWarnings("deprecation")
+ public MethodBinding createMethodBinding(String s, Class[] classes) throws ReferenceSyntaxException {
+ weaveDelegate();
+ return _delegate.createMethodBinding(s, classes);
+ }
+
+ public Iterator<Locale> getSupportedLocales() {
+ weaveDelegate();
+ return _delegate.getSupportedLocales();
+ }
+
+ public void setSupportedLocales(Collection<Locale> locales) {
+ weaveDelegate();
+ _delegate.setSupportedLocales(locales);
+ }
+
+ public void addValidator(String s, String s1) {
+ weaveDelegate();
+ _delegate.addValidator(s, s1);
+ }
+
+ public Validator createValidator(String s) throws FacesException {
+ weaveDelegate();
+
+ Validator retVal = _delegate.createValidator(s);
+ if (WeavingContext.isDynamic(retVal.getClass()) && !Proxy.isProxyClass(retVal.getClass())) {
+ retVal = (Validator) reloadInstance(retVal, ScriptingConst.ARTIFACT_TYPE_VALIDATOR);
+ }
+ return retVal;
+ }
+
+ public Iterator<String> getValidatorIds() {
+ weaveDelegate();
+ return _delegate.getValidatorIds();
+ }
+
+ @SuppressWarnings("deprecation")
+ public ValueBinding createValueBinding(String s) throws ReferenceSyntaxException {
+ weaveDelegate();
+ return _delegate.createValueBinding(s);
+ }
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+ private Object reloadInstance(Object instance, int artefactType) {
+ if (instance == null) {
+ return null;
+ }
+ if (WeavingContext.isDynamic(instance.getClass()) && !alreadyWovenInRequest(instance.getClass().getName())) {
+ instance = WeavingContext.getWeaver().reloadScriptingInstance(instance, artefactType);
+ alreadyWovenInRequest(instance.getClass().getName());
+ }
+ return instance;
+ }
+
+ private boolean alreadyWovenInRequest(String clazz) {
+ //portlets now can be enabled thanks to the jsf2 indirections regarding the external context
+ Map<String,Object> reqMap = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
+ if (reqMap.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
+ reqMap.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
+ return false;
+ }
+ return true;
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ELResolverProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,102 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.el.ELContext;
+import javax.el.ELException;
+import javax.el.ELResolver;
+import java.util.Iterator;
+
+/**
+ * EL Resolver which is scripting enabled
+ *
+ * @author Werner Punz
+ */
+public class ELResolverProxy extends ELResolver implements Decorated {
+
+ ELResolver _delegate = null;
+
+ public Object getValue(ELContext elContext, final Object base, final Object property) throws NullPointerException, ELException {
+ //request, class is loaded anew hence we already have picked up the new code
+
+ Object retVal = _delegate.getValue(elContext, base, property);
+
+ if (retVal != null && WeavingContext.isDynamic(retVal.getClass())) {
+ //now here we have something special which is implicit
+ //if the bean is only request scoped we dont have to reload anything
+ //so just run through this code without having anything happening here
+ //reloadScriptingInstance will return the same object we already had before
+ //the reason is for request or none scoped beans we get a new
+ //freshly reloaded and compiled instance on every request
+ //the problem starts with session application or custom scoped beans
+ //There nothing is compiled and we have to do the further bean processing
+
+ Object newRetVal = WeavingContext.getWeaver().reloadScriptingInstance(retVal, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN); /*once it was tainted or loaded by
+ our classloader we have to recreate all the time to avoid classloader issues*/
+ if (newRetVal != retVal) {
+ setValue(elContext, base, property, newRetVal);
+ }
+ return newRetVal;
+ }
+
+ return retVal;
+
+ }
+
+ public Class<?> getType(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
+ Class<?> retVal = _delegate.getType(elContext, o, o1);
+ if (retVal != null && WeavingContext.isDynamic(retVal)) {
+ return WeavingContext.getWeaver().reloadScriptingClass(retVal);
+ }
+ return retVal;
+ }
+
+ public void setValue(ELContext elContext, Object base, Object property, Object newRetVal) throws NullPointerException, ELException {
+ //now to more complex relations...
+ if (base != null) {
+ WeavingContext.getRefreshContext().getDependencyRegistry().addDependency(ScriptingConst.ENGINE_TYPE_JSF_ALL, base.getClass().getName(), base.getClass().getName(), newRetVal.getClass().getName());
+ }
+ _delegate.setValue(elContext, base, property, newRetVal);
+ }
+
+ public boolean isReadOnly(ELContext elContext, Object o, Object o1) throws NullPointerException, ELException {
+ return _delegate.isReadOnly(elContext, o, o1);
+ }
+
+ public Iterator getFeatureDescriptors(ELContext elContext, Object o) {
+ return _delegate.getFeatureDescriptors(elContext, o);
+ }
+
+ public Class<?> getCommonPropertyType(ELContext elContext, Object o) {
+ return _delegate.getCommonPropertyType(elContext, o);
+ }
+
+ public ELResolverProxy(ELResolver delegate) {
+ _delegate = delegate;
+ }
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/FacesContextProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,145 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ExternalContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.application.Application;
+import javax.faces.application.FacesMessage;
+import javax.faces.render.RenderKit;
+import javax.faces.component.UIViewRoot;
+import javax.el.ELContext;
+import java.util.Iterator;
+
+/**
+ * A reloading, weaving faces context
+ * this is needed because groovy fails on
+ * the introspection of the standard java myfaces
+ * faces context due to pending references
+ * of the _impl into the portlet context
+ * not sure if this works in portlets
+ * though
+ *
+ * @author Werner Punz
+ */
+public class FacesContextProxy extends FacesContext implements Decorated {
+
+ public FacesContext _delegate = null;
+
+ private void weaveDelegate() {
+ if (_delegate != null)
+ _delegate = (FacesContext) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_FACESCONTEXT);
+ }
+
+ public ELContext getELContext() {
+ return _delegate.getELContext();
+ }
+
+ public Application getApplication() {
+ return _delegate.getApplication();
+ }
+
+ public Iterator<String> getClientIdsWithMessages() {
+ return _delegate.getClientIdsWithMessages();
+ }
+
+ public ExternalContext getExternalContext() {
+ return _delegate.getExternalContext();
+ }
+
+ public FacesMessage.Severity getMaximumSeverity() {
+ return _delegate.getMaximumSeverity();
+ }
+
+ public Iterator<FacesMessage> getMessages() {
+ return _delegate.getMessages();
+ }
+
+ public Iterator<FacesMessage> getMessages(String s) {
+ return _delegate.getMessages(s);
+ }
+
+ public RenderKit getRenderKit() {
+ return _delegate.getRenderKit();
+ }
+
+ public boolean getRenderResponse() {
+ return _delegate.getRenderResponse();
+ }
+
+ public boolean getResponseComplete() {
+ return _delegate.getResponseComplete();
+ }
+
+ public ResponseStream getResponseStream() {
+ return _delegate.getResponseStream();
+ }
+
+ public void setResponseStream(ResponseStream responseStream) {
+ _delegate.setResponseStream(responseStream);
+ }
+
+ public ResponseWriter getResponseWriter() {
+ return _delegate.getResponseWriter();
+ }
+
+ public void setResponseWriter(ResponseWriter responseWriter) {
+ _delegate.setResponseWriter(responseWriter);
+ }
+
+ public UIViewRoot getViewRoot() {
+ return _delegate.getViewRoot();
+ }
+
+ public void setViewRoot(UIViewRoot uiViewRoot) {
+ weaveDelegate();//perfect place no matter what the viewRoot is about once per request set
+ _delegate.setViewRoot(uiViewRoot);
+ }
+
+ public void addMessage(String s, FacesMessage facesMessage) {
+ _delegate.addMessage(s, facesMessage);
+ }
+
+ public void release() {
+ _delegate.release();
+ }
+
+ public void renderResponse() {
+ _delegate.renderResponse();
+ }
+
+ public void responseComplete() {
+ _delegate.responseComplete();
+ }
+
+ public FacesContextProxy(FacesContext delegate) {
+ _delegate = delegate;
+ weaveDelegate();
+ }
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/LifefcycleProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,80 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.lifecycle.Lifecycle;
+import javax.faces.event.PhaseListener;
+import javax.faces.context.FacesContext;
+import javax.faces.FacesException;
+
+/**
+ * Scripting enabled lifecycle
+ *
+ * @author Werner Punz
+ */
+public class LifefcycleProxy extends Lifecycle implements Decorated {
+
+ private void weaveDelegate() {
+ if (_delegate != null)
+ _delegate = (Lifecycle) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_LIFECYCLE);
+ }
+
+ public LifefcycleProxy(Lifecycle delegate) {
+ _delegate = delegate;
+ }
+
+ public void addPhaseListener(PhaseListener phaseListener) {
+ weaveDelegate();
+ /*we can put our object weaving code into the add here*/
+ if (WeavingContext.isDynamic(phaseListener.getClass()))
+ phaseListener = (PhaseListener) WeavingContext.createMethodReloadingProxyFromObject(phaseListener, PhaseListener.class, ScriptingConst.ARTIFACT_TYPE_PHASELISTENER);
+
+ _delegate.addPhaseListener(phaseListener);
+ }
+
+ public void execute(FacesContext facesContext) throws FacesException {
+ weaveDelegate();
+ _delegate.execute(facesContext);
+ }
+
+ public PhaseListener[] getPhaseListeners() {
+ weaveDelegate();
+ return _delegate.getPhaseListeners();
+ }
+
+ public void removePhaseListener(PhaseListener phaseListener) {
+ weaveDelegate();
+ _delegate.removePhaseListener(phaseListener);
+ }
+
+ public void render(FacesContext facesContext) throws FacesException {
+ weaveDelegate();
+ _delegate.render(facesContext);
+ }
+
+ Lifecycle _delegate = null;
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/NavigationHandlerProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,54 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ * A reloading navigation handler
+ *
+ * @author Werner Punz
+ */
+public class NavigationHandlerProxy extends NavigationHandler implements Decorated {
+
+ private void weaveDelegate() {
+ _delegate = (NavigationHandler) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_NAVIGATIONHANDLER);
+ }
+
+ public NavigationHandlerProxy(NavigationHandler delegate) {
+ super();
+ _delegate = delegate;
+ }
+
+ public void handleNavigation(FacesContext facesContext, String s, String s1) {
+ weaveDelegate();
+ _delegate.handleNavigation(facesContext, s, s1);
+ }
+
+ NavigationHandler _delegate;
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/RenderkitProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,107 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.context.FacesContext;
+import javax.faces.context.ResponseStream;
+import javax.faces.context.ResponseWriter;
+import javax.faces.render.RenderKit;
+import javax.faces.render.Renderer;
+import javax.faces.render.ResponseStateManager;
+import javax.servlet.ServletRequest;
+import java.io.OutputStream;
+import java.io.Writer;
+
+/**
+ * Weaving renderkit which
+ * acts as a proxy factory for
+ * our internal reloading referers
+ *
+ * @author Werner Punz
+ */
+public class RenderkitProxy extends RenderKit implements Decorated {
+
+ RenderKit _delegate = null;
+
+ public RenderkitProxy(RenderKit delegate) {
+ _delegate = delegate;
+ }
+
+ public void addRenderer(String componentFamily, String rendererType, Renderer renderer) {
+ weaveDelegate();
+ //wo do it brute force here because we have sometimes casts and hence cannot rely on proxies
+ //renderers itself are flyweight patterns which means they are shared over objects
+ renderer = (Renderer) reloadInstance(renderer, ScriptingConst.ARTIFACT_TYPE_RENDERER);
+ _delegate.addRenderer(componentFamily, rendererType, renderer);
+ }
+
+ public Renderer getRenderer(String componentFamily, String rendererType) {
+ weaveDelegate();
+ return (Renderer) reloadInstance(_delegate.getRenderer(componentFamily, rendererType), ScriptingConst.ARTIFACT_TYPE_RENDERER);
+ }
+
+ public ResponseStateManager getResponseStateManager() {
+ weaveDelegate();
+ return _delegate.getResponseStateManager();
+ }
+
+ public ResponseWriter createResponseWriter(Writer writer, String s, String s1) {
+ weaveDelegate();
+ return (ResponseWriter) reloadInstance(_delegate.createResponseWriter(writer, s, s1), ScriptingConst.ARTIFACT_TYPE_RESPONSEWRITER);
+ }
+
+ public ResponseStream createResponseStream(OutputStream outputStream) {
+ weaveDelegate();
+ return (ResponseStream) reloadInstance(_delegate.createResponseStream(outputStream), ScriptingConst.ARTIFACT_TYPE_RESPONSESTREAM);
+ }
+
+ public Object getDelegate() {
+ return _delegate;
+ }
+
+ private final void weaveDelegate() {
+ _delegate = (RenderKit) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_RENDERKIT);
+ }
+
+ private final Object reloadInstance(Object instance, int artefactType) {
+ if (instance == null) {
+ return null;
+ }
+ if (WeavingContext.isDynamic(instance.getClass()) && !alreadyWovenInRequest(instance.getClass().getName())) {
+ instance = WeavingContext.getWeaver().reloadScriptingInstance(instance, artefactType);
+ alreadyWovenInRequest(instance.getClass().getName());
+ }
+ return instance;
+ }
+
+ private final boolean alreadyWovenInRequest(String clazz) {
+ //portlets now can be enabled thanks to the jsf2 indirections regarding the external context
+ ServletRequest req = (ServletRequest) FacesContext.getCurrentInstance().getExternalContext().getRequest();
+ if (req.getAttribute(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
+ req.setAttribute(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
+ return false;
+ }
+ return true;
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/VariableResolverProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,53 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.el.*;
+
+import javax.faces.context.FacesContext;
+
+/**
+ * objects loaded must
+ * be checked if a reloading is needed
+ *
+ * @author Werner Punz
+ */
+@SuppressWarnings("deprecation")
+public class VariableResolverProxy extends VariableResolver implements Decorated {
+ VariableResolver _delegate;
+
+ public VariableResolverProxy(VariableResolver delegate) {
+ _delegate = delegate;
+ }
+
+ public Object resolveVariable(FacesContext facesContext, String s) throws EvaluationException {
+ Object variable = _delegate.resolveVariable(facesContext, s);
+ if (variable != null && WeavingContext.isDynamic(variable.getClass()))
+ variable = WeavingContext.getWeaver().reloadScriptingInstance(variable, ScriptingConst.ARTIFACT_TYPE_MANAGEDBEAN);
+ return variable;
+ }
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/java/org/apache/myfaces/extensions/scripting/jsf/dynamicdecorators/implemetations/ViewHandlerProxy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,104 @@
+/*
+ * 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.extensions.scripting.jsf.dynamicdecorators.implemetations;
+
+import org.apache.myfaces.extensions.scripting.api.Decorated;
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+
+import javax.faces.application.ViewHandler;
+import javax.faces.context.FacesContext;
+import javax.faces.component.UIViewRoot;
+import javax.faces.FacesException;
+import java.util.Locale;
+import java.io.IOException;
+
+/**
+ * Scripting enabled View Handler
+ *
+ * @author Werner Punz
+ */
+public class ViewHandlerProxy extends ViewHandler implements Decorated {
+
+ ViewHandler _delegate = null;
+
+ private void weaveDelegate() {
+ if (_delegate != null) {
+ _delegate = (ViewHandler) WeavingContext.getWeaver().reloadScriptingInstance(_delegate, ScriptingConst.ARTIFACT_TYPE_VIEWHANDLER);
+ }
+ }
+
+ public ViewHandlerProxy(ViewHandler delegate) {
+ _delegate = delegate;
+ }
+
+ public String calculateCharacterEncoding(FacesContext facesContext) {
+ weaveDelegate();
+ return _delegate.calculateCharacterEncoding(facesContext);
+ }
+
+ public Locale calculateLocale(FacesContext facesContext) {
+ weaveDelegate();
+ return _delegate.calculateLocale(facesContext);
+ }
+
+ public String calculateRenderKitId(FacesContext facesContext) {
+ weaveDelegate();
+ return _delegate.calculateRenderKitId(facesContext);
+ }
+
+ public UIViewRoot createView(FacesContext facesContext, String s) {
+ weaveDelegate();
+ return _delegate.createView(facesContext, s);
+ }
+
+ public String getActionURL(FacesContext facesContext, String s) {
+ weaveDelegate();
+ return _delegate.getActionURL(facesContext, s);
+ }
+
+ public String getResourceURL(FacesContext facesContext, String s) {
+ weaveDelegate();
+ return _delegate.getResourceURL(facesContext, s);
+ }
+
+ public void initView(FacesContext facesContext) throws FacesException {
+ weaveDelegate();
+ _delegate.initView(facesContext);
+ }
+
+ public void renderView(FacesContext facesContext, UIViewRoot uiViewRoot) throws IOException, FacesException {
+ weaveDelegate();
+ _delegate.renderView(facesContext, uiViewRoot);
+ }
+
+ public UIViewRoot restoreView(FacesContext facesContext, String s) {
+ weaveDelegate();
+ return _delegate.restoreView(facesContext, s);
+ }
+
+ public void writeState(FacesContext facesContext) throws IOException {
+ weaveDelegate();
+ _delegate.writeState(facesContext);
+ }
+
+ public Object getDelegate() {
+ return _delegate; //To change body of implemented methods use File | Settings | File Templates.
+ }
+}
Modified: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/resources/META-INF/faces-config.xml?rev=933379&r1=933378&r2=933379&view=diff
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/resources/META-INF/faces-config.xml (original)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces12-extensions/src/main/resources/META-INF/faces-config.xml Mon Apr 12 19:43:30 2010
@@ -29,44 +29,44 @@
issue is we have to make a codeweaving for every bean created
-->
<application-factory>
- org.apache.myfaces.scripting.jsf.dynamicdecorators.factories.ScriptingApplicationFactory
+ org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingApplicationFactory
</application-factory>
<faces-context-factory>
- org.apache.myfaces.scripting.jsf.dynamicdecorators.factories.ScriptingFacesContextFactory
+ org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingFacesContextFactory
</faces-context-factory>
<lifecycle-factory>
- org.apache.myfaces.scripting.jsf.dynamicdecorators.factories.ScriptingLifecycleFactory
+ org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingLifecycleFactory
</lifecycle-factory>
<render-kit-factory>
- org.apache.myfaces.scripting.jsf.dynamicdecorators.factories.ScriptingRenderkitFactory
+ org.apache.myfaces.extensions.scripting.jsf.dynamicdecorators.factories.ScriptingRenderkitFactory
</render-kit-factory>
</factory>
<lifecycle>
- <phase-listener>org.apache.myfaces.scripting.jsf.RefreshPhaseListener</phase-listener>
+ <phase-listener>org.apache.myfaces.extensions.scripting.jsf.RefreshPhaseListener</phase-listener>
</lifecycle>
<component>
- <component-type>org.apache.myfaces.scripting.components.CompilerComponent</component-type>
- <component-class>org.apache.myfaces.scripting.components.CompilerComponent</component-class>
+ <component-type>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-type>
+ <component-class>org.apache.myfaces.extensions.scripting.components.CompilerComponent</component-class>
</component>
<component>
- <component-type>org.apache.myfaces.scripting.components.TaintHistory</component-type>
- <component-class>org.apache.myfaces.scripting.components.TaintHistory</component-class>
+ <component-type>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-type>
+ <component-class>org.apache.myfaces.extensions.scripting.components.TaintHistory</component-class>
</component>
<render-kit>
<renderer>
<component-family>javax.faces.Output</component-family>
- <renderer-type>org.apache.myfaces.scripting.components.CompilerComponentRenderer</renderer-type>
- <renderer-class>org.apache.myfaces.scripting.components.CompilerComponentRenderer</renderer-class>
+ <renderer-type>org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer</renderer-type>
+ <renderer-class>org.apache.myfaces.extensions.scripting.components.CompilerComponentRenderer</renderer-class>
</renderer>
<renderer>
<component-family>javax.faces.Output</component-family>
- <renderer-type>org.apache.myfaces.scripting.components.TaintHistoryRenderer</renderer-type>
- <renderer-class>org.apache.myfaces.scripting.components.TaintHistoryRenderer</renderer-class>
+ <renderer-type>org.apache.myfaces.extensions.scripting.components.TaintHistoryRenderer</renderer-type>
+ <renderer-class>org.apache.myfaces.extensions.scripting.components.TaintHistoryRenderer</renderer-class>
</renderer>
</render-kit>
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/faces-config.NavData
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/faces-config.NavData?rev=933379&view=auto
==============================================================================
(empty)
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/BehaviorHandlerReloadingStrategy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,68 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
+import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
+import org.apache.myfaces.extensions.scripting.core.util.Cast;
+import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
+
+import javax.faces.view.facelets.BehaviorConfig;
+import javax.faces.view.facelets.BehaviorHandler;
+import javax.faces.view.facelets.ComponentHandler;
+
+/**
+ * The reloading strategy for our behavior tag handlers
+ * note since we do not have an official api we must
+ * enforce a getConverterConfig() method to allow
+ * the reloading of converter tag handlers
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class BehaviorHandlerReloadingStrategy extends SimpleReloadingStrategy {
+ public BehaviorHandlerReloadingStrategy(ScriptingWeaver weaver) {
+ super(weaver);
+ }
+
+ @Override
+ public Object reload(Object scriptingInstance, int artifactType) {
+ if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
+ Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+ if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+ //class of this object has not changed although
+ // reload is enabled we can skip the rest now
+ return scriptingInstance;
+ }
+ BehaviorHandler oldHandler = (BehaviorHandler) scriptingInstance;
+ /**
+ *
+ */
+ BehaviorConfig config = (BehaviorConfig) ReflectUtil.executeMethod(oldHandler, "getBehaviorConfig");
+ BehaviorHandler newHandler = (BehaviorHandler) ReflectUtil.instantiate(aclass, new Cast(BehaviorConfig.class, config));
+
+ //save all pending non config related properties wherever possible
+ super.mapProperties(newHandler, oldHandler);
+
+ return newHandler;
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ComponentHandlerReloadingStrategy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
+import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
+import org.apache.myfaces.extensions.scripting.core.util.Cast;
+import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
+
+import javax.faces.view.facelets.ComponentConfig;
+import javax.faces.view.facelets.ComponentHandler;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ComponentHandlerReloadingStrategy extends SimpleReloadingStrategy {
+
+ public ComponentHandlerReloadingStrategy(ScriptingWeaver weaver) {
+ super(weaver);
+ }
+
+ @Override
+ public Object reload(Object scriptingInstance, int artifactType) {
+ if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
+ Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+ if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+ //class of this object has not changed although
+ // reload is enabled we can skip the rest now
+ return scriptingInstance;
+ }
+ ComponentHandler oldHandler = (ComponentHandler) scriptingInstance;
+ ComponentConfig config = oldHandler.getComponentConfig();
+ ComponentHandler newHandler = (ComponentHandler) ReflectUtil.instantiate(aclass, new Cast(ComponentConfig.class, config));
+
+ //save all pending non config related properties wherever possible
+ super.mapProperties(newHandler, oldHandler);
+
+ return newHandler;
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ConverterHandlerReloadingStrategy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,67 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
+import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
+import org.apache.myfaces.extensions.scripting.core.util.Cast;
+import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
+
+import javax.faces.view.facelets.*;
+
+/**
+ * The reloading strategy for our converter tag handlers
+ * note since we do not have an official api we must
+ * enforce a getConverterConfig() method to allow
+ * the reloading of converter tag handlers
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+@SuppressWarnings("unused")//used dynamically
+public class ConverterHandlerReloadingStrategy extends SimpleReloadingStrategy {
+
+ public ConverterHandlerReloadingStrategy(ScriptingWeaver weaver) {
+ super(weaver);
+ }
+
+ @Override
+ public Object reload(Object scriptingInstance, int artifactType) {
+ if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
+ Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+ if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+ //class of this object has not changed although
+ // reload is enabled we can skip the rest now
+ return scriptingInstance;
+ }
+ ConverterHandler oldHandler = (ConverterHandler) scriptingInstance;
+ /**
+ *
+ */
+ ConverterConfig config = (ConverterConfig) ReflectUtil.executeMethod(oldHandler, "getConverterConfig");
+ ConverterHandler newHandler = (ConverterHandler) ReflectUtil.instantiate(aclass, new Cast(ConverterConfig.class, config));
+
+ //save all pending non config related properties wherever possible
+ super.mapProperties(newHandler, oldHandler);
+
+ return newHandler;
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingBehaviorTagHandlerDelegate.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,67 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.view.facelets.tag.jsf.BehaviorTagHandlerDelegate;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.*;
+import java.io.IOException;
+
+/**
+ * Behavior Tag Handler which introduces reloading behavior
+ *
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ReloadingBehaviorTagHandlerDelegate extends TagHandlerDelegate {
+
+ BehaviorHandler _owner;
+ TagHandlerDelegate _delegate;
+
+ public ReloadingBehaviorTagHandlerDelegate(BehaviorHandler owner) {
+ applyOwner(owner);
+ }
+
+ private void applyOwner(BehaviorHandler owner) {
+ _owner = owner;
+ _delegate = new BehaviorTagHandlerDelegate(_owner);
+ }
+
+ @Override
+ public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
+ if (WeavingContext.isDynamic(_owner.getClass())) {
+ BehaviorHandler newOwner = (BehaviorHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_BEHAVIOR_HANDLER);
+ if (!newOwner.getClass().equals(_owner.getClass())) {
+ applyOwner(newOwner);
+ }
+ }
+ _owner.apply(ctx, comp);
+ }
+
+ @Override
+ public MetaRuleset createMetaRuleset(Class type) {
+ return _delegate.createMetaRuleset(type);
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingComponentTagHandlerDelegate.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,104 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.extensions.scripting.facelet.support.ComponentRule;
+import org.apache.myfaces.extensions.scripting.facelet.support.SwitchingMetarulesetImpl;
+import org.apache.myfaces.view.facelets.tag.jsf.*;
+
+import javax.faces.component.ActionSource;
+import javax.faces.component.EditableValueHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.ValueHolder;
+import javax.faces.view.facelets.*;
+import javax.faces.view.facelets.ComponentHandler;
+import java.io.IOException;
+
+/**
+ * we provide our own component tag handler factory impl
+ * so that we can deal with refreshing of components
+ * on Facelets level without running into
+ * nasty type exceptions
+ */
+public class ReloadingComponentTagHandlerDelegate extends TagHandlerDelegate {
+
+ ComponentHandler _owner;
+ TagHandlerDelegate _delegate;
+
+ public ReloadingComponentTagHandlerDelegate(ComponentHandler owner) {
+ applyOwner(owner);
+ }
+
+ private void applyOwner(ComponentHandler owner) {
+ _owner = owner;
+ _delegate = new ComponentTagHandlerDelegate(_owner);
+ }
+
+ @Override
+ public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
+ if (WeavingContext.isDynamic(_owner.getClass())) {
+ ComponentHandler newOwner = (ComponentHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_COMPONENT_HANDLER);
+ if (!newOwner.getClass().equals(_owner.getClass())) {
+ applyOwner(newOwner);
+ }
+ }
+ _delegate.apply(ctx, comp);
+ }
+
+ public MetaRuleset createMetaRuleset(Class type) {
+ //We have to create a different meta rule set for dynamic classes
+ //which have weaver instantiation criteria, the original meta rule set
+ //first applies the attributes and then calls BeanPropertyTagRule
+ //that one however caches the current method and does not take into consideration
+ //that classes can be changed on the fly
+
+ // if (WeavingContext.isDynamic(type)) {
+ MetaRuleset m = new SwitchingMetarulesetImpl(_owner.getTag(), type);
+ // ignore standard component attributes
+ m.ignore("binding").ignore("id");
+
+ // add auto wiring for attributes
+ m.addRule(ComponentRule.Instance);
+
+ // if it's an ActionSource
+ if (ActionSource.class.isAssignableFrom(type)) {
+ m.addRule(ActionSourceRule.Instance);
+ }
+
+ // if it's a ValueHolder
+ if (ValueHolder.class.isAssignableFrom(type)) {
+ m.addRule(ValueHolderRule.Instance);
+
+ // if it's an EditableValueHolder
+ if (EditableValueHolder.class.isAssignableFrom(type)) {
+ m.ignore("submittedValue");
+ m.ignore("valid");
+ m.addRule(EditableValueHolderRule.Instance);
+ }
+ }
+
+ return m;
+ //}
+
+ //return _delegate.createMetaRuleset(type);
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingConverterTagHandlerDelegate.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,65 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.view.facelets.tag.jsf.ConverterTagHandlerDelegate;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.*;
+import java.io.IOException;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ReloadingConverterTagHandlerDelegate extends TagHandlerDelegate {
+
+ ConverterHandler _owner;
+ TagHandlerDelegate _delegate;
+
+ public ReloadingConverterTagHandlerDelegate(ConverterHandler owner) {
+ applyOwner(owner);
+ }
+
+ private void applyOwner(ConverterHandler owner) {
+ _owner = owner;
+ _delegate = new ConverterTagHandlerDelegate(_owner);
+ }
+
+ @Override
+ public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
+ if (WeavingContext.isDynamic(_owner.getClass())) {
+ ConverterHandler newOwner = (ConverterHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_CONVERTER_HANDLER);
+ if(!newOwner.getClass().equals(_owner.getClass())) {
+ applyOwner(newOwner);
+ }
+ }
+ _delegate.apply(ctx, comp);
+ }
+
+ @Override
+ public MetaRuleset createMetaRuleset(Class type) {
+ return _delegate.createMetaRuleset(type);
+ }
+
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReloadingValidatorTagHandlerDelegate.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,67 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingConst;
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.view.facelets.tag.jsf.ValidatorTagHandlerDelegate;
+
+import javax.faces.component.UIComponent;
+import javax.faces.view.facelets.FaceletContext;
+import javax.faces.view.facelets.MetaRuleset;
+import javax.faces.view.facelets.TagHandlerDelegate;
+import javax.faces.view.facelets.ValidatorHandler;
+import java.io.IOException;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ReloadingValidatorTagHandlerDelegate extends TagHandlerDelegate {
+
+ ValidatorHandler _owner;
+ TagHandlerDelegate _delegate;
+
+ public ReloadingValidatorTagHandlerDelegate(ValidatorHandler owner) {
+ applyOwner(owner);
+ }
+
+ private void applyOwner(ValidatorHandler owner) {
+ _owner = owner;
+ _delegate = new ValidatorTagHandlerDelegate(_owner);
+ }
+
+ @Override
+ public void apply(FaceletContext ctx, UIComponent comp) throws IOException {
+ if (WeavingContext.isDynamic(_owner.getClass())) {
+ ValidatorHandler newOwner = (ValidatorHandler) WeavingContext.getWeaver().reloadScriptingInstance(_owner, ScriptingConst.ARTIFACT_TYPE_VALIDATOR_HANDLER);
+ if (!newOwner.getClass().equals(_owner.getClass())) {
+ applyOwner(newOwner);
+ }
+ }
+ _owner.apply(ctx, comp);
+ }
+
+ @Override
+ public MetaRuleset createMetaRuleset(Class type) {
+ return _delegate.createMetaRuleset(type);
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ReroutingResourceResolver.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,46 @@
+package org.apache.myfaces.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.view.facelets.impl.DefaultResourceResolver;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.List;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * decorated Facelet resource resolver to reroute
+ * the resource requests to our source path if possible
+ */
+public class ReroutingResourceResolver extends DefaultResourceResolver {
+
+ DefaultResourceResolver _delegate = new DefaultResourceResolver();
+ volatile boolean _initiated = false;
+ List<String> _resourceDirs = null;
+
+ Logger log = Logger.getLogger(this.getClass().getName());
+
+ @Override
+ public URL resolveUrl(String path) {
+
+ if (!_initiated) {
+ _resourceDirs = WeavingContext.getConfiguration().getResourceDirs();
+ _initiated = true;
+ }
+
+ if (_resourceDirs != null && !_resourceDirs.isEmpty()) {
+ for (String resourceDir : _resourceDirs) {
+ File resource = new File(resourceDir + path);
+ if (resource.exists()) try {
+ return resource.toURI().toURL();
+ } catch (MalformedURLException e) {
+ log.log(Level.SEVERE, "",e);
+ }
+ }
+ }
+
+ return _delegate.resolveUrl(path);
+ }
+}
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/TagHandlerDelegateFactoryImpl.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.core.util.WeavingContext;
+import org.apache.myfaces.view.facelets.tag.jsf.BehaviorTagHandlerDelegate;
+import org.apache.myfaces.view.facelets.tag.jsf.ComponentTagHandlerDelegate;
+import org.apache.myfaces.view.facelets.tag.jsf.ConverterTagHandlerDelegate;
+import org.apache.myfaces.view.facelets.tag.jsf.ValidatorTagHandlerDelegate;
+
+import javax.faces.view.facelets.*;
+
+/**
+ * Tag handler delegate factory which injects reloading
+ * proxies for our facelet artifacts
+ */
+public class TagHandlerDelegateFactoryImpl extends TagHandlerDelegateFactory {
+
+ @Override
+ public TagHandlerDelegate createBehaviorHandlerDelegate(
+ BehaviorHandler owner) {
+ if (WeavingContext.isDynamic(owner.getClass())) {
+ return new ReloadingBehaviorTagHandlerDelegate(owner);
+ } else {
+ return new BehaviorTagHandlerDelegate(owner);
+ }
+ }
+
+ @Override
+ public TagHandlerDelegate createComponentHandlerDelegate(
+ ComponentHandler owner) {
+ return new ReloadingComponentTagHandlerDelegate(owner);
+ }
+
+ @Override
+ public TagHandlerDelegate createConverterHandlerDelegate(
+ ConverterHandler owner) {
+ if (WeavingContext.isDynamic(owner.getClass())) {
+ return new ReloadingConverterTagHandlerDelegate(owner);
+ } else {
+ return new ConverterTagHandlerDelegate(owner);
+ }
+ }
+
+ @Override
+ public TagHandlerDelegate createValidatorHandlerDelegate(
+ ValidatorHandler owner) {
+ if (WeavingContext.isDynamic(owner.getClass())) {
+ return new ReloadingValidatorTagHandlerDelegate(owner);
+ } else {
+ return new ValidatorTagHandlerDelegate(owner);
+ }
+ }
+}
+
Added: myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java?rev=933379&view=auto
==============================================================================
--- myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java (added)
+++ myfaces/extensions/scripting/trunk/extscript-core-root/extscript-myfaces2-extensions/src/main/java/org/apache/myfaces/extensions/scripting/facelet/ValidatorHandlerReloadingStrategy.java Mon Apr 12 19:43:30 2010
@@ -0,0 +1,60 @@
+/*
+ * 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.extensions.scripting.facelet;
+
+import org.apache.myfaces.extensions.scripting.api.ScriptingWeaver;
+import org.apache.myfaces.extensions.scripting.core.reloading.SimpleReloadingStrategy;
+import org.apache.myfaces.extensions.scripting.core.util.Cast;
+import org.apache.myfaces.extensions.scripting.core.util.ReflectUtil;
+
+import javax.faces.view.facelets.*;
+
+/**
+ * @author Werner Punz (latest modification by $Author$)
+ * @version $Revision$ $Date$
+ */
+
+public class ValidatorHandlerReloadingStrategy extends SimpleReloadingStrategy {
+
+ public ValidatorHandlerReloadingStrategy(ScriptingWeaver weaver) {
+ super(weaver);
+ }
+
+ @Override
+ public Object reload(Object scriptingInstance, int artifactType) {
+ if (!(scriptingInstance instanceof ComponentHandler)) return scriptingInstance;
+ Class aclass = _weaver.reloadScriptingClass(scriptingInstance.getClass());
+ if (aclass.hashCode() == scriptingInstance.getClass().hashCode()) {
+ //class of this object has not changed although
+ // reload is enabled we can skip the rest now
+ return scriptingInstance;
+ }
+ ValidatorHandler oldHandler = (ValidatorHandler) scriptingInstance;
+ ValidatorConfig config = oldHandler.getValidatorConfig();
+ ValidatorHandler newHandler = (ValidatorHandler) ReflectUtil.instantiate(aclass, new Cast(ValidatorConfig.class, config));
+
+ //save all pending non config related properties wherever possible
+ super.mapProperties(newHandler, oldHandler);
+
+ return newHandler;
+ }
+
+}
+