@@ -26,6 +27,8 @@
+
+
diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.js b/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.js
new file mode 100644
index 00000000000..a6ec08193aa
--- /dev/null
+++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.js
@@ -0,0 +1,52 @@
+/*
+ * Copyright 2014-2018 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+export function truncateJavaType(javaType) {
+ return javaType.replace(/java\.[^A-Z]*/g, '');
+}
+
+/**
+ * Truncates the given package name to the given length.
+ *
+ * It works similar to {@link https://logback.qos.ch/manual/layouts.html#conversionWord}
+ *
+ * @param javaType
+ * @param length
+ * @returns {string|*}
+ */
+export function truncatePackageName(javaType, length) {
+ const split = javaType.split('.');
+ if (length > 0) {
+ const clazzName = split.pop();
+
+ let shortened;
+ for (let i = 0; i <= split.length; i++) {
+ shortened = [
+ ...[...split].splice(0, i).map(p => p.charAt(0)),
+ ...[...split].splice(i),
+ clazzName
+ ].join('.');
+
+ if (shortened.length <= length) {
+ return shortened;
+ }
+ }
+
+ return shortened;
+ } else {
+ return split?.pop();
+ }
+}
diff --git a/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.spec.js b/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.spec.js
new file mode 100644
index 00000000000..7f754d4cac7
--- /dev/null
+++ b/spring-boot-admin-server-ui/src/main/frontend/views/instances/jolokia/utils.spec.js
@@ -0,0 +1,36 @@
+/*
+ * Copyright 2014-2018 the original author or authors.
+ *
+ * Licensed 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.
+ */
+
+import {truncateJavaType, truncatePackageName} from '@/views/instances/jolokia/utils';
+
+describe('utils.js', () => {
+ it('truncateJavaType', () => {
+ expect(truncateJavaType('java.lang.String')).toEqual('String');
+ });
+
+ it.each`
+ length | expected
+ ${0} | ${'Bar'}
+ ${5} | ${'m.s.s.Bar'}
+ ${10} | ${'m.s.s.Bar'}
+ ${15} | ${'m.s.sample.Bar'}
+ ${16} | ${'m.sub.sample.Bar'}
+ ${26} | ${'mainPackage.sub.sample.Bar'}
+ `('truncatePackageName having length $length', ({expected, length}) => {
+ const result = truncatePackageName('mainPackage.sub.sample.Bar', length);
+ expect(result).toEqual(expected);
+ });
+});