1
14
15 package com.liferay.util.bridges.ruby;
16
17 import com.liferay.portal.kernel.log.Log;
18 import com.liferay.portal.kernel.log.LogFactoryUtil;
19 import com.liferay.util.bridges.bsf.BaseBSFPortlet;
20
21 import org.apache.bsf.BSFException;
22
23 import org.jruby.RubyException;
24 import org.jruby.exceptions.RaiseException;
25
26
31 public class RubyPortlet extends BaseBSFPortlet {
32
33 protected String getFileParam() {
34 return _FILE_PARAM;
35 }
36
37 protected String getScriptingEngineClassName() {
38 return _SCRIPTING_ENGINE_CLASS_NAME;
39 }
40
41 protected String getScriptingEngineExtension() {
42 return _SCRIPTING_ENGINE_EXTENSION;
43 }
44
45 protected String getScriptingEngineLanguage() {
46 return _SCRIPTING_ENGINE_LANGUAGE;
47 }
48
49 protected void logBSFException(BSFException bsfe, String path) {
50 String message =
51 "The script at " + path + " or one of the global files has errors.";
52
53 Throwable t = bsfe.getTargetException();
54
55 if (t instanceof RaiseException) {
56 RubyException re = ((RaiseException)t).getException();
57
58 message +=
59 re.message + " (" + re.getMetaClass().toString() + ")";
60
61 _log.error(message);
62
63 if (_log.isDebugEnabled()) {
64 _log.debug(t, t);
65 }
66 }
67 else {
68 _log.error(message, t);
69 }
70 }
71
72 private static final String _FILE_PARAM = "rubyFile";
73
74 private static final String _SCRIPTING_ENGINE_CLASS_NAME =
75 "org.jruby.javasupport.bsf.JRubyEngine";
76
77 private static final String _SCRIPTING_ENGINE_EXTENSION = "rb";
78
79 private static final String _SCRIPTING_ENGINE_LANGUAGE = "ruby";
80
81 private static Log _log = LogFactoryUtil.getLog(RubyPortlet.class);
82
83 }