All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.logicbus.xscript.SvcLocate Maven / Gradle / Ivy

There is a newer version: 1.6.17
Show newest version
package com.logicbus.xscript;

import com.alogic.xscript.ExecuteWatcher;
import com.alogic.xscript.Logiclet;
import com.alogic.xscript.LogicletContext;
import com.alogic.xscript.doc.XsObject;
import com.alogic.xscript.plugins.Segment;
import com.anysoft.util.Properties;
import com.anysoft.util.PropertiesConstants;
import com.anysoft.util.Settings;
import com.logicbus.backend.ServantFactory;
import com.logicbus.backend.ServantRegistry;
import com.logicbus.models.catalog.Path;
import com.logicbus.models.servant.ServiceDescription;
import org.apache.commons.lang3.StringUtils;

/**
 * 定位到具体的服务
 *
 * @since 1.6.13.7 [20200812 duanyy] 
*/ public class SvcLocate extends Segment { protected String $path = ""; protected boolean doSwagger = false; public SvcLocate(String tag, Logiclet p) { super(tag, p); } @Override public void configure(Properties p){ super.configure(p); $path = PropertiesConstants.transform(p,"path",$path); doSwagger = PropertiesConstants.getBoolean(p,"swagger",doSwagger); } @Override protected void onExecute(XsObject root, XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { String path = PropertiesConstants.transform(ctx,$path,""); if (StringUtils.isNotEmpty(path)) { Settings settings = Settings.get(); ServantFactory sf = (ServantFactory) settings.get("servantFactory"); ServantRegistry sm = sf.getServantRegistry(); ServiceDescription sd = sm.get(new Path(path)); if (sd != null){ LogicletContext childCtx = new LogicletContext(ctx); childCtx.SetValue("$id",sd.getServiceID()); childCtx.SetValue("$name",sd.getName()); childCtx.SetValue("$note",sd.getNote()); childCtx.SetValue("$module",sd.getModule()); childCtx.SetValue("$visible",sd.getVisible()); childCtx.SetValue("$path",sd.getPath()); childCtx.SetValue("$log",sd.getLogType().toString()); childCtx.SetValue("$acGroup",sd.getAcGroup()); childCtx.SetValue("$privilege", StringUtils.isEmpty(sd.getPrivilege())?sd.getPath():sd.getPrivilege()); childCtx.SetValue("$desc", String.format("%s\n\n**Module**:%s\n\n**Visible**:%s\n\n**Log Type**:%s\n\n**Access Control Group**:%s\n\n**Privilage**:%s", sd.getNote(),sd.getModule(),sd.getVisible(),sd.getLogType().toString(),sd.getAcGroup(),sd.getPrivilege())); String swagger = "false"; if (doSwagger){ Logiclet onSwagger = sd.getSwaggerLogiclet(); if (onSwagger != null){ onSwagger.execute(root,current,childCtx,watcher); swagger = "true"; } } childCtx.SetValue("$swagger",swagger); super.onExecute(root, current, childCtx, watcher); } } } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy