release version 1.10.0
This commit is contained in:
@ -0,0 +1,62 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* object-producing-shell
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.producer.shell;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.Option;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
|
||||
import ru.entaxy.platform.base.support.karaf.shell.ShellTableExt;
|
||||
import ru.entaxy.platform.core.producer.api.EntaxyProducerUtils;
|
||||
|
||||
@Service
|
||||
@Command(scope = EntaxyProducerServiceSupport.SCOPE, name = "factory-essence")
|
||||
public class FactoryEssence extends FactoryAwareCommand {
|
||||
|
||||
@Option(name = "-p", aliases = {"--prefix"})
|
||||
String prefix = "";
|
||||
|
||||
@Override
|
||||
protected Object doExecute() throws Exception {
|
||||
|
||||
Map<String, Object> essence = EntaxyProducerUtils.getFactoryEssence(entaxyFactory, prefix);
|
||||
|
||||
ShellTableExt table = new ShellTableExt();
|
||||
table.column("Key");
|
||||
table.column("Value");
|
||||
|
||||
for (Map.Entry<String, Object> entry : essence.entrySet())
|
||||
table.addRow().addContent(entry.getKey(), entry.getValue() == null ? "" : entry.getValue().toString());
|
||||
|
||||
// print output
|
||||
table.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,91 @@
|
||||
/*-
|
||||
* ~~~~~~licensing~~~~~~
|
||||
* object-producing-shell
|
||||
* ==========
|
||||
* Copyright (C) 2020 - 2024 EmDev LLC
|
||||
* ==========
|
||||
* You may not use this file except in accordance with the License Terms of the Copyright
|
||||
* Holder located at: https://entaxy.ru/eula . All copyrights, all intellectual property
|
||||
* rights to the Software and any copies are the property of the Copyright Holder. Unless
|
||||
* it is explicitly allowed the Copyright Holder, the User is prohibited from using the
|
||||
* Software for commercial purposes to provide services to third parties.
|
||||
*
|
||||
* The Copyright Holder hereby declares that the Software is provided on an "AS IS".
|
||||
* Under no circumstances does the Copyright Holder guarantee or promise that the
|
||||
* Software provided by him will be suitable or not suitable for the specific purposes
|
||||
* of the User, that the Software will meet all commercial and personal subjective
|
||||
* expectations of the User, that the Software will work properly, without technical
|
||||
* errors, quickly and uninterruptedly.
|
||||
*
|
||||
* Under no circumstances shall the Copyright Holder or its Affiliates is not liable
|
||||
* to the User for any direct or indirect losses of the User, his expenses or actual
|
||||
* damage, including, downtime; loss of bussines; lost profit; lost earnings; loss
|
||||
* or damage to data, property, etc.
|
||||
* ~~~~~~/licensing~~~~~~
|
||||
*/
|
||||
package ru.entaxy.platform.core.producer.shell;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.apache.karaf.shell.api.action.Action;
|
||||
import org.apache.karaf.shell.api.action.Argument;
|
||||
import org.apache.karaf.shell.api.action.Command;
|
||||
import org.apache.karaf.shell.api.action.lifecycle.Service;
|
||||
import org.osgi.framework.Filter;
|
||||
import org.osgi.framework.FrameworkUtil;
|
||||
import org.osgi.framework.InvalidSyntaxException;
|
||||
|
||||
import ru.entaxy.platform.base.objects.factory.EntaxyFactory;
|
||||
import ru.entaxy.platform.base.support.karaf.shell.ShellTableExt;
|
||||
|
||||
@Service
|
||||
@Command(scope = "producer", name = "factory-find")
|
||||
public class FindFactories extends EntaxyProducerServiceSupport implements Action {
|
||||
|
||||
@Argument(index = 0, required = true)
|
||||
String filter;
|
||||
|
||||
@Override
|
||||
public Object execute() throws Exception {
|
||||
|
||||
Filter osgiFilter = null;
|
||||
|
||||
try {
|
||||
osgiFilter = FrameworkUtil.createFilter(filter);
|
||||
} catch (InvalidSyntaxException e) {
|
||||
|
||||
// print error
|
||||
System.err.println("Invalid filter:");
|
||||
e.printStackTrace(System.err);
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
List<EntaxyFactory> factories =
|
||||
producerService.findFactories(osgiFilter).stream().sorted(new Comparator<EntaxyFactory>() {
|
||||
|
||||
@Override
|
||||
public int compare(EntaxyFactory o1, EntaxyFactory o2) {
|
||||
return o1.getId().compareToIgnoreCase(o2.getId());
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
|
||||
ShellTableExt table = new ShellTableExt();
|
||||
|
||||
table.column("Id");
|
||||
table.column("Type");
|
||||
|
||||
for (EntaxyFactory f : factories)
|
||||
table.addRow().addContent(f.getId(), f.getType());
|
||||
|
||||
// print output
|
||||
table.print(System.out);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user