Skip to content

Commit

Permalink
https://issues.apache.org/jira/browse/EXTSCRIPT-135
Browse files Browse the repository at this point in the history
  • Loading branch information
werpu committed Jun 28, 2010
1 parent c3ed202 commit 9cd3d4b
Show file tree
Hide file tree
Showing 13 changed files with 352 additions and 43 deletions.
Expand Up @@ -380,18 +380,26 @@ protected boolean isRecompileRecommended() {
}

protected boolean isFullyRecompiled() {
FacesContext context = FacesContext.getCurrentInstance();
return context != null && context.getExternalContext().getRequestMap().containsKey(this.getClass().getName() + "_recompiled");
try {
FacesContext context = FacesContext.getCurrentInstance();
return context != null && context.getExternalContext().getRequestMap().containsKey(this.getClass().getName() + "_recompiled");
} catch (UnsupportedOperationException ex) {
//still in startup
return false;
}
}

public void markAsFullyRecompiled() {
FacesContext context = FacesContext.getCurrentInstance();
if (context != null) {
//mark the request as tainted with recompile
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
requestMap.put(this.getClass().getName() + "_recompiled", Boolean.TRUE);
try {
FacesContext context = FacesContext.getCurrentInstance();
if (context != null) {
//mark the request as tainted with recompile
Map<String, Object> requestMap = context.getExternalContext().getRequestMap();
requestMap.put(this.getClass().getName() + "_recompiled", Boolean.TRUE);
}
WeavingContext.getRefreshContext().setRecompileRecommended(getScriptingEngine(), Boolean.FALSE);
} catch (UnsupportedOperationException ex) {
}
WeavingContext.getRefreshContext().setRecompileRecommended(getScriptingEngine(), Boolean.FALSE);
}

/**
Expand Down Expand Up @@ -471,6 +479,8 @@ private void recompileRefresh() {
fullRecompile();
//we update our dependencies and annotation info prior to going
//into the refresh cycle


fullClassScan();
}

Expand Down
Expand Up @@ -246,22 +246,31 @@ public void setDependencyRegistry(int scriptingEngine, DependencyRegistry regist
}

public boolean isDependencyScanned(int scriptingEngine) {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx == null) {
try {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx == null) {
return false;
}
Map<String, Object> requestMap = (Map<String, Object>) ctx.getExternalContext().getRequestMap();
Boolean retVal = (Boolean) requestMap.get("isDependencyScanned_" + scriptingEngine);
return (retVal == null) ? false : retVal;
} catch (UnsupportedOperationException ex) {
//still in startup
return false;
}
Map<String, Object> requestMap = (Map<String, Object>) ctx.getExternalContext().getRequestMap();
Boolean retVal = (Boolean) requestMap.get("isDependencyScanned_" + scriptingEngine);
return (retVal == null) ? false : retVal;
}

public void setDependencyScanned(int scriptingEngine, Boolean val) {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx == null) {
return;
try {
FacesContext ctx = FacesContext.getCurrentInstance();
if (ctx == null) {
return;
}
Map<String, Object> requestMap = (Map<String, Object>) ctx.getExternalContext().getRequestMap();
requestMap.put("isDependencyScanned_" + scriptingEngine, val);
} catch (UnsupportedOperationException ex) {
//still in startup
}
Map<String, Object> requestMap = (Map<String, Object>) ctx.getExternalContext().getRequestMap();
requestMap.put("isDependencyScanned_" + scriptingEngine, val);
}

public FileChangedDaemon getDaemon() {
Expand Down
Expand Up @@ -66,7 +66,8 @@ public void preInit(ServletContextEvent servletContextEvent) {
private void initCompileAndScan() {
if (WeavingContext.isScriptingEnabled()) {
_log.info("[EXT-SCRIPTING] Compiling all sources for the first time");
WeavingContext.getWeaver().postStartupActions();
//WeavingContext.getWeaver().postStartupActions();
WeavingContext.getWeaver().fullRecompile();
}
}

Expand Down Expand Up @@ -94,6 +95,7 @@ private void initContext(ServletContext servletContext) {

public void postInit(ServletContextEvent evt) {
//tell the system that the startup phase is done
WeavingContext.getWeaver().fullClassScan();
evt.getServletContext().setAttribute(ScriptingConst.CTX_ATTR_STARTUP, new AtomicBoolean(Boolean.FALSE));
}

Expand Down
Expand Up @@ -95,13 +95,17 @@ private final Object reloadInstance(Object instance, int artefactType) {
}

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;
try {//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;
} catch(UnsupportedOperationException ex) {
//still in startup no additional weaving here
return true;
}
return true;
}

}
Expand Up @@ -56,7 +56,7 @@ public void addRenderer(String componentFamily, String rendererType, Renderer re
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);
Expand All @@ -78,7 +78,6 @@ public Renderer getRenderer(String componentFamily, String rendererType) {
return rendr;
}


private ClientBehaviorRenderer handleAnnotationChangeBehaviorRenderer(String s) {
ClientBehaviorRenderer rendr2;

Expand Down Expand Up @@ -117,7 +116,6 @@ public ResponseStream createResponseStream(OutputStream outputStream) {
return (ResponseStream) reloadInstance(_delegate.createResponseStream(outputStream), ScriptingConst.ARTIFACT_TYPE_RESPONSESTREAM);
}


@Override
public void addClientBehaviorRenderer(String s, ClientBehaviorRenderer renderer) {

Expand Down Expand Up @@ -182,13 +180,19 @@ private Object reloadInstance(Object instance, int artefactType) {
}

private boolean alreadyWovenInRequest(String clazz) {
//portlets now can be enabled thanks to the jsf2 indirections regarding the external context
Map<String, Object> req = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if (req.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
req.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
return false;
try {//portlets now can be enabled thanks to the jsf2 indirections regarding the external context

//portlets now can be enabled thanks to the jsf2 indirections regarding the external context
Map<String, Object> req = FacesContext.getCurrentInstance().getExternalContext().getRequestMap();
if (req.get(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz) == null) {
req.put(ScriptingConst.SCRIPTING_REQUSINGLETON + clazz, "");
return false;
}
return true;
} catch (UnsupportedOperationException ex) {
//still in startup no additional weaving here
return true;
}
return true;
}

}
Expand Up @@ -28,6 +28,16 @@
/**
* @author Werner Punz (latest modification by $Author$)
* @version $Revision$ $Date$
*
* Problem the resource request is issued on servlet level before
* our compile triggers can trigger from the phase listener
* this is evil
*
* We probably have to reissue the compile from the resource handler
* directly upfront :-( or mark the resource handler as something like double tainted!
*
* This problem will resolve itself with async compile
*
*/

public class ResourceHandlerProxy extends ResourceHandler {
Expand Down Expand Up @@ -67,6 +77,7 @@ public boolean isResourceRequest(FacesContext context) {
}

public boolean libraryExists(String libraryName) {
weaveDelegate();
return _delegate.libraryExists(libraryName);
}

Expand Down
Expand Up @@ -83,6 +83,7 @@
</resource-handler>
</application>


<!--
<application>
<system-event-listener>
Expand All @@ -92,5 +93,6 @@
</system-event-listener>
</application>
-->
-->

</faces-config>
Expand Up @@ -39,7 +39,7 @@
</description>
<param-name>org.apache.myfaces.extensions.scripting.groovy.LOADER_PATHS</param-name>
<param-value>
/Users/werpu2/development/workspace/extension-scripting4/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy
/Users/werpu2/development/workspace/1_0_final_prepare/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/groovy
</param-value>
</context-param>

Expand All @@ -50,15 +50,15 @@
</description>
<param-name>org.apache.myfaces.extensions.scripting.java.LOADER_PATHS</param-name>
<param-value>
/Users/werpu2/development/workspace/extension-scripting4/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java
/Users/werpu2/development/workspace/1_0_final_prepare/extscript-examples/myfaces20-example/src/main/webapp/WEB-INF/java
</param-value>
</context-param>

<context-param>
<description>resource paths for our custom JSF2 resource resolver</description>
<param-name>org.apache.myfaces.extensions.scripting.resources.LOADER_PATHS</param-name>
<param-value>
/Users/werpu2/development/workspace/extension-scripting4/extscript-examples/myfaces20-example/src/main/webapp
/Users/werpu2/development/workspace/1_0_final_prepare/extscript-examples/myfaces20-example/src/main/webapp
</param-value>
</context-param>

Expand Down

0 comments on commit 9cd3d4b

Please sign in to comment.