Skip to content

Commit c5aa844

Browse files
JihoonKim1004JihoonKim1004
authored andcommitted
Made the capability of providing Flash to JavaScript log level within web.xml's com.googlecode.jsfFlex.FlashToJavaScriptLogLevel parameter.
1 parent 23c2be6 commit c5aa844

12 files changed

Lines changed: 352 additions & 193 deletions

File tree

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package com.googlecode.jsfFlex.shared.beans.others;
20+
21+
/**
22+
* @author Ji Hoon Kim
23+
*/
24+
public final class JsfFlexFlashApplicationConfiguration {
25+
26+
private String _flashToJavaScriptLogMode;
27+
28+
public JsfFlexFlashApplicationConfiguration(){
29+
super();
30+
}
31+
32+
public String getFlashToJavaScriptLogMode() {
33+
return _flashToJavaScriptLogMode;
34+
}
35+
public void setFlashToJavaScriptLogMode(String flashToJavaScriptLogMode) {
36+
_flashToJavaScriptLogMode = flashToJavaScriptLogMode;
37+
}
38+
39+
}

jsf-flex-shared/core/src/main/java/com/googlecode/jsfFlex/shared/context/MxmlContext.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Map;
2323

2424
import com.googlecode.jsfFlex.shared.beans.additionalScriptContent.AdditionalApplicationScriptContent;
25+
import com.googlecode.jsfFlex.shared.beans.others.JsfFlexFlashApplicationConfiguration;
2526
import com.googlecode.jsfFlex.shared.tasks._CommonTaskRunner;
2627
import com.googlecode.jsfFlex.shared.tasks._FileManipulatorTaskRunner;
2728
import com.googlecode.jsfFlex.shared.tasks._FlexTaskRunner;
@@ -58,6 +59,8 @@ public abstract class MxmlContext {
5859

5960
public abstract void setFlexSDKPath(String flexSDKPath);
6061

62+
public abstract JsfFlexFlashApplicationConfiguration getJsfFlexFlashApplicationConfiguration();
63+
6164
public abstract String getMxmlPath();
6265

6366
public abstract void setMxmlPath(String mxmlPath);

jsf-flex-shared/core/src/main/java/com/googlecode/jsfFlex/shared/context/MxmlContextImpl.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
import com.googlecode.jsfFlex.shared.adapter._MXMLApplicationContract;
2727
import com.googlecode.jsfFlex.shared.beans.additionalScriptContent.AdditionalApplicationScriptContent;
28+
import com.googlecode.jsfFlex.shared.beans.others.JsfFlexFlashApplicationConfiguration;
2829
import com.googlecode.jsfFlex.shared.tasks._CommonTaskRunner;
2930
import com.googlecode.jsfFlex.shared.tasks._FileManipulatorTaskRunner;
3031
import com.googlecode.jsfFlex.shared.tasks._FlexTaskRunner;
@@ -46,6 +47,7 @@ public class MxmlContextImpl extends MxmlContext {
4647

4748
private final Map _preMxmlCompMap;
4849
private final AdditionalApplicationScriptContent _additionalAppScriptContent;
50+
private final JsfFlexFlashApplicationConfiguration _jsfFlexFlashApplicationConfiguration;
4951
private final List _applicationInitValueList;
5052

5153
private final String _currMxml;
@@ -71,6 +73,7 @@ public MxmlContextImpl(String currMxml, _MXMLApplicationContract currApplication
7173
_currMxml = currMxml;
7274
_preMxmlCompMap = new TreeMap();
7375
_additionalAppScriptContent = new AdditionalApplicationScriptContent(_currMxml, currApplicationContract);
76+
_jsfFlexFlashApplicationConfiguration = new JsfFlexFlashApplicationConfiguration();
7477
_applicationInitValueList = new LinkedList();
7578
_runnerFactoryInstance = _RunnerFactory.getInstance();
7679
_flexRunner = _runnerFactoryInstance.getFlexTaskRunnerImpl();
@@ -106,6 +109,9 @@ public String getFlexSDKPath() {
106109
public void setFlexSDKPath(String flexSDKPath) {
107110
_flexSDKPath = flexSDKPath;
108111
}
112+
public JsfFlexFlashApplicationConfiguration getJsfFlexFlashApplicationConfiguration() {
113+
return _jsfFlexFlashApplicationConfiguration;
114+
}
109115
public String getMxmlPath() {
110116
return _mxmlPath;
111117
}

jsf-flex-shared/core/src/main/java/com/googlecode/jsfFlex/shared/util/MXMLConstants.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,13 @@
3939
*/
4040
public final class MXMLConstants {
4141

42+
public static final String FLASH_TO_JAVASCRIPT_LOG_LEVEL_NAME = "com.googlecode.jsfFlex.FlashToJavaScriptLogLevel";
43+
public static final String FLASH_TO_JAVASCRIPT_LOG_LOG_LEVEL = "Log";
44+
public static final String FLASH_TO_JAVASCRIPT_LOG_DEBUG_LEVEL = "Debug";
45+
public static final String FLASH_TO_JAVASCRIPT_LOG_INFO_LEVEL = "Info";
46+
public static final String FLASH_TO_JAVASCRIPT_LOG_WARN_LEVEL = "Warn";
47+
public static final String FLASH_TO_JAVASCRIPT_LOG_ERROR_LEVEL = "Error";
48+
4249
public static final String CONFIG_MODE_NAME = "com.googlecode.jsfFlex.MODE";
4350
public static final String SIMPLY_SWF_MODE = "simplySwfMode";
4451
public static final String PRODUCTION_MODE = "productionMode";

jsf-flex-shared/core/src/main/resources/com/googlecode/jsfFlex/shared/actionScript/com/googlecode/jsfFlex/communication/core/ComponentValueMapper.as

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ package com.googlecode.jsfFlex.communication.core
6565
_loader = new URLLoader();
6666

6767
_loader.addEventListener(Event.COMPLETE, function (event:Event):void {
68-
var _loader:URLLoader = URLLoader(event.target);
6968
_loader.removeEventListener(Event.COMPLETE, arguments.callee, false);
7069
_compValueMapper = new XML(_loader.data);
7170
});

jsf-flex-shared/core/src/main/resources/com/googlecode/jsfFlex/shared/actionScript/com/googlecode/jsfFlex/communication/logger/AbstractLogger.as

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,41 +25,108 @@
2525
package com.googlecode.jsfFlex.communication.logger
2626
{
2727
import flash.errors.IllegalOperationError;
28+
import flash.events.Event;
29+
30+
import flash.net.URLLoader;
31+
import flash.net.URLRequest;
32+
33+
import flash.utils.clearInterval;
34+
import flash.utils.setInterval;
2835

2936
internal class AbstractLogger implements ILogger {
3037

31-
private static const LOG_MODE:int = {logModeToken};
38+
private static const JSF_FLEX_FLASH_APPLICATION_CONFIG:String = "swf/jsfFlexFlashApplicationConfig.xml";
39+
private static const PRIOR_TO_LOG_MODE_SETTING_MESSAGES:Array = new Array();
40+
41+
private static var _clearIntervalRef:uint;
42+
private static var _logMode:int = -1;
43+
private static var _loader:URLLoader;
44+
45+
{
46+
_clearIntervalRef = setInterval( logPreLogModeSettingMessages, 500);
47+
_loader = new URLLoader();
48+
49+
_loader.addEventListener(Event.COMPLETE, function (event:Event):void {
50+
_loader.removeEventListener(Event.COMPLETE, arguments.callee, false);
51+
var jsfFlexFlashApplicationConfig:XML = new XML(_loader.data);
52+
_logMode = int(jsfFlexFlashApplicationConfig.flash_to_javascript_log_level.toString());
53+
clearInterval(_clearIntervalRef);
54+
logPreLogModeSettingMessages();
55+
});
56+
57+
try{
58+
_loader.load(new URLRequest(JSF_FLEX_FLASH_APPLICATION_CONFIG));
59+
}catch(loadingError:Error){
60+
trace("Failure in loading of the jsfFlexFlashApplicationConfig.xml file");
61+
}
62+
}
63+
64+
public static function logPreLogModeSettingMessages():void {
65+
66+
if(_logMode < 0){
67+
return;
68+
}
69+
70+
for each(var messageObject:Object in PRIOR_TO_LOG_MODE_SETTING_MESSAGES){
71+
var currSeverity:int = messageObject.severity;
72+
var currFunction:Function = messageObject.method;
73+
if(_logMode < currSeverity){
74+
currFunction.call(messageObject.instanceRef, messageObject.message, (currSeverity - 1));
75+
}
76+
}
77+
78+
}
3279

3380
public function AbstractLogger(logClass:Class) {
3481
super();
3582
}
3683

3784
public function log(errorMessage:String):void {
38-
if(LOG_MODE < 2){
85+
if(_logMode == -1){
86+
PRIOR_TO_LOG_MODE_SETTING_MESSAGES.push({instanceRef: this, method: logMessage, message: errorMessage, severity: 2});
87+
return;
88+
}
89+
if(_logMode < 2){
3990
logMessage(errorMessage, 1);
4091
}
4192
}
4293

4394
public function logDebug(errorMessage:String):void {
44-
if(LOG_MODE < 3){
95+
if(_logMode == -1){
96+
PRIOR_TO_LOG_MODE_SETTING_MESSAGES.push({instanceRef: this, method: logMessage, message: errorMessage, severity: 3});
97+
return;
98+
}
99+
if(_logMode < 3){
45100
logMessage(errorMessage, 2);
46101
}
47102
}
48103

49104
public function logInfo(errorMessage:String):void {
50-
if(LOG_MODE < 4){
105+
if(_logMode == -1){
106+
PRIOR_TO_LOG_MODE_SETTING_MESSAGES.push({instanceRef: this, method: logMessage, message: errorMessage, severity: 4});
107+
return;
108+
}
109+
if(_logMode < 4){
51110
logMessage(errorMessage, 3);
52111
}
53112
}
54113

55114
public function logWarn(errorMessage:String):void {
56-
if(LOG_MODE < 5){
115+
if(_logMode == -1){
116+
PRIOR_TO_LOG_MODE_SETTING_MESSAGES.push({instanceRef: this, method: logMessage, message: errorMessage, severity: 5});
117+
return;
118+
}
119+
if(_logMode < 5){
57120
logMessage(errorMessage, 4);
58121
}
59122
}
60123

61124
public function logError(errorMessage:String):void {
62-
if(LOG_MODE < 6){
125+
if(_logMode == -1){
126+
PRIOR_TO_LOG_MODE_SETTING_MESSAGES.push({instanceRef: this, method: logMessage, message: errorMessage, severity: 6});
127+
return;
128+
}
129+
if(_logMode < 6){
63130
logMessage(errorMessage, 5);
64131
}
65132
}

jsf-flex/core/src/main/java/com/googlecode/jsfFlex/component/ext/AbstractMXMLUIApplication.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
import com.googlecode.jsfFlex.renderkit.html.util.JsfFlexDojoResource;
6363
import com.googlecode.jsfFlex.shared.adapter._MXMLApplicationContract;
6464
import com.googlecode.jsfFlex.shared.adapter._MXMLContract;
65+
import com.googlecode.jsfFlex.shared.beans.others.JsfFlexFlashApplicationConfiguration;
6566
import com.googlecode.jsfFlex.shared.context.MxmlContext;
6667
import com.googlecode.jsfFlex.shared.context.MxmlContextImpl;
6768
import com.googlecode.jsfFlex.shared.tasks._RunnerFactory;
@@ -272,15 +273,15 @@ public void encodeBegin(FacesContext context) throws IOException {
272273

273274
MxmlContext mxmlContext = new MxmlContextImpl(getMxmlPackageName(), this);
274275

275-
Object mode = context.getExternalContext().getInitParameter(MXMLConstants.CONFIG_MODE_NAME);
276+
String mode = context.getExternalContext().getInitParameter(MXMLConstants.CONFIG_MODE_NAME);
276277

277278
boolean isSimplySwf = false;
278279
boolean isProduction = true;
279280

280281
if(mode != null){
281282

282-
isSimplySwf = mode.toString().equals(MXMLConstants.SIMPLY_SWF_MODE);
283-
isProduction = mode.toString().equals(MXMLConstants.PRODUCTION_MODE);
283+
isSimplySwf = mode.equals(MXMLConstants.SIMPLY_SWF_MODE);
284+
isProduction = mode.equals(MXMLConstants.PRODUCTION_MODE);
284285

285286
}
286287

@@ -328,6 +329,31 @@ public void encodeBegin(FacesContext context) throws IOException {
328329
mxmlContext.setSwfBasePath(swfBasePath);
329330
mxmlContext.setSwcPath(swcPath);
330331

332+
//set the attributes for jsfFlexFlashApplicationConfiguration
333+
JsfFlexFlashApplicationConfiguration jsfFlexFlashApplicationConfiguration = mxmlContext.getJsfFlexFlashApplicationConfiguration();
334+
String flashToJavaScriptLogLevel = context.getExternalContext().getInitParameter(MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_LEVEL_NAME);
335+
if(flashToJavaScriptLogLevel == null){
336+
337+
flashToJavaScriptLogLevel = context.getExternalContext().getInitParameter(MXMLConstants.CONFIG_MODE_NAME);
338+
if(flashToJavaScriptLogLevel.equals(MXMLConstants.PRODUCTION_MODE)){
339+
flashToJavaScriptLogLevel = MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_WARN_LEVEL;
340+
}else{
341+
flashToJavaScriptLogLevel = MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_LOG_LEVEL;
342+
}
343+
}
344+
345+
if(flashToJavaScriptLogLevel.equals(MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_LOG_LEVEL)){
346+
jsfFlexFlashApplicationConfiguration.setFlashToJavaScriptLogMode("1");
347+
}else if(flashToJavaScriptLogLevel.equals(MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_DEBUG_LEVEL)){
348+
jsfFlexFlashApplicationConfiguration.setFlashToJavaScriptLogMode("2");
349+
}else if(flashToJavaScriptLogLevel.equals(MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_INFO_LEVEL)){
350+
jsfFlexFlashApplicationConfiguration.setFlashToJavaScriptLogMode("3");
351+
}else if(flashToJavaScriptLogLevel.equals(MXMLConstants.FLASH_TO_JAVASCRIPT_LOG_WARN_LEVEL)){
352+
jsfFlexFlashApplicationConfiguration.setFlashToJavaScriptLogMode("4");
353+
}else {
354+
jsfFlexFlashApplicationConfiguration.setFlashToJavaScriptLogMode("5");
355+
}
356+
331357
if(isSimplySwf){
332358
//do not need to create preMXML files
333359

0 commit comments

Comments
 (0)