Skip to content

Commit ec02850

Browse files
committed
fix issue: when user library used slf4j logging service, it will conflict with Act used sl4j logging service due to class loader issue; TemplatePathResolver now allow XLS and XLSX format; NetworkHandler: ContentSuffixSensor now support xls and xlsx suffix
1 parent f26c01f commit ec02850

5 files changed

Lines changed: 21 additions & 5 deletions

File tree

src/main/java/act/app/ActionContext.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ public boolean acceptJson() {
188188
return accept() == H.Format.JSON;
189189
}
190190

191-
public boolean isXML() {
191+
public boolean acceptXML() {
192192
return accept() == H.Format.XML;
193193
}
194194

src/main/java/act/boot/app/FullStackAppBootstrapClassLoader.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,11 +272,11 @@ private void buildIndex() {
272272
@Override
273273
protected Class<?> loadClass(String name, boolean resolve) throws ClassNotFoundException {
274274
Class<?> c = findLoadedClass(name);
275-
if (c != null) {
275+
if (null != c) {
276276
return c;
277277
}
278278

279-
if (name.startsWith("java") || name.startsWith("org.osgl")) {
279+
if (name.startsWith("java") || name.startsWith("org.osgl") || name.startsWith("org.slf4j")) {
280280
return super.loadClass(name, resolve);
281281
}
282282

src/main/java/act/controller/Controller.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ public static Result inferResult(HandlerMethodMetaInfo meta, Object v, ActionCon
679679
DisableFastJsonCircularReferenceDetect.option.set(false);
680680
}
681681
}
682-
} else if (context.isXML()) {
682+
} else if (context.acceptXML()) {
683683
PropertySpec.MetaInfo propertySpec = (null == meta) ? null : meta.propertySpec();
684684
return new FilteredRenderXML(v, propertySpec, context);
685685
} else if (context.accept() == H.Format.CSV) {

src/main/java/act/view/TemplatePathResolver.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,6 @@ protected String amendSuffix(String path, ActContext context) {
6262
}
6363

6464
public static boolean isAcceptFormatSupported(H.Format fmt) {
65-
return (UNKNOWN == fmt || HTML == fmt || JSON == fmt || XML == fmt || TXT == fmt || CSV == fmt);
65+
return (UNKNOWN == fmt || HTML == fmt || JSON == fmt || XML == fmt || TXT == fmt || CSV == fmt || XLS == fmt || XLSX == fmt);
6666
}
6767
}

src/main/java/act/xio/NetworkHandler.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ private static class ContentSuffixSensor implements $.Func2<H.Request, String, S
145145
private static final char[] json = {'j', 's', 'o'};
146146
private static final char[] xml = {'x', 'm'};
147147
private static final char[] csv = {'c', 's'};
148+
private static final char[] xls = {'x', 'l', 's'};
149+
private static final char[] xlsx = {'x', 'l', 's', 'x'};
150+
private static final char[] pdf = {'p', 'd', 'f'};
148151

149152
@Override
150153
public String apply(H.Request req, String url) throws NotAppliedException, Osgl.Break {
@@ -167,6 +170,19 @@ public String apply(H.Request req, String url) throws NotAppliedException, Osgl.
167170
trait = csv;
168171
fmt = H.Format.CSV;
169172
break;
173+
case 'f':
174+
trait = pdf;
175+
fmt = H.Format.PDF;
176+
break;
177+
case 's':
178+
trait = xls;
179+
fmt = H.Format.XLS;
180+
break;
181+
case 'x':
182+
sepPos = 4;
183+
trait = xlsx;
184+
fmt = H.Format.XLSX;
185+
break;
170186
default:
171187
return url;
172188
}

0 commit comments

Comments
 (0)