本文整理汇总了Java中org.osgl.util.S类的典型用法代码示例。如果您正苦于以下问题:Java S类的具体用法?Java S怎么用?Java S使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
S类属于org.osgl.util包,在下文中一共展示了S类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: managedFields
import org.osgl.util.S; //导入依赖的package包/类
public List<String> managedFields(String className) {
List<String> fields = managedFieldByClass.get(className);
if (null == fields) {
fields = C.newList();
Set<String> ss = storageFields();
for (String s: ss) {
if (s.startsWith(className + ":")) {
String fn = S.after(s, ":");
if (S.notEmpty(fn)) {
fields.add(fn);
}
}
}
managedFieldByClass.put(className, fields);
}
return fields;
}
示例2: initService
import org.osgl.util.S; //导入依赖的package包/类
private void initService(String ssId, Map<String, String> conf) {
Map<String, String> svcConf = C.newMap();
String prefix = "ss." + (S.empty(ssId) ? "" : ssId + ".");
for (String key : conf.keySet()) {
if (key.startsWith(prefix)) {
String o = conf.get(key);
svcConf.put(key.substring(prefix.length()), o);
}
}
String impl = svcConf.remove("impl");
String svcId = S.empty(ssId) ? DEFAULT : ssId;
if (null == impl) {
throw new ConfigurationException("Cannot init storage service[%s]: implementation not specified", svcId);
}
StoragePlugin plugin = StoragePluginManager.instance().plugin(impl);
if (null == plugin) {
throw new ConfigurationException("Cannot init storage service[%s]: implementation not found", svcId);
}
svcConf.put(IStorageService.CONF_ID, "".equals(ssId) ? DEFAULT : ssId);
IStorageService svc = plugin.initStorageService(ssId, app(), svcConf);
serviceById.put(svcId, svc);
logger.info("storage service[%s] initialized", svcId);
}
示例3: initStorageService
import org.osgl.util.S; //导入依赖的package包/类
@Override
protected IStorageService initStorageService(String id, App app, Map<String, String> conf) {
conf = calibrate(conf, "storage.fs.");
FileSystemService ss = new FileSystemService(conf);
ss.setKeyNameProvider(UploadFileStorageService.ACT_STORAGE_KEY_NAME_PROVIDER);
String home = conf.get(CONF_HOME_DIR);
String url = ss.getStaticWebEndpoint();
if (null != url) {
if (!url.endsWith("/")) {
url = url + "/";
}
if (S.notBlank(url) && !url.startsWith("http") && !url.startsWith("//")) {
App.instance().router().addMapping(H.Method.GET, url, new FileGetter(new File(home)), RouteSource.BUILD_IN);
}
}
return ss;
}
示例4: register
import org.osgl.util.S; //导入依赖的package包/类
/**
* Register this binder to `Genie`
*
* @param genie the dependency injector
*/
public void register(Genie genie) {
if (null == provider) {
if (null != constructor) {
provider = genie.buildConstructor(
constructor,
BeanSpec.of(constructor.getDeclaringClass(), null, genie),
new HashSet<BeanSpec>());
} else if (null != impl) {
provider = new LazyProvider<>(impl, genie);
}
}
if (!bound()) {
throw new InjectException("Cannot register without binding specified");
}
BeanSpec spec = beanSpec(genie);
genie.addIntoRegistry(spec, genie.decorate(spec, provider, true), annotations.isEmpty() && S.blank(name));
if (fireEvent || forceFireEvent) {
genie.fireProviderRegisteredEvent(type);
}
}
示例5: registerFactoryMethod
import org.osgl.util.S; //导入依赖的package包/类
private void registerFactoryMethod(final Object instance, final Method factory) {
Type retType = factory.getGenericReturnType();
Annotation[] factoryAnnotations = factory.getAnnotations();
final BeanSpec spec = BeanSpec.of(retType, factoryAnnotations, this);
final MethodInjector methodInjector = methodInjector(factory, C.<BeanSpec>empty());
addIntoRegistry(spec, decorate(spec, new Provider() {
@Override
public Object get() {
return methodInjector.applyTo(instance);
}
@Override
public String toString() {
return S.fmt("%s::%s", instance.getClass().getName(), methodInjector.method.getName());
}
}, true), factoryAnnotations.length == 0);
fireProviderRegisteredEvent(spec.rawType());
}
示例6: invoke
import org.osgl.util.S; //导入依赖的package包/类
@Override
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
String methodName = method.getName();
if (S.eq("hashCode", methodName)) {
return hashCode();
} else if (S.eq("equals", methodName)) {
return equals(args[0]);
} else if (S.eq("annotationType", methodName)) {
return type;
} else if (S.eq("toString", methodName)) {
return toString();
}
Object result = method.getDefaultValue();
if (result == null) {
throw new IncompleteAnnotationException(type, methodName);
}
return result;
}
示例7: toString
import org.osgl.util.S; //导入依赖的package包/类
@Override
public String toString() {
StringBuilder sb = S.builder(type());
if (S.notBlank(name)) {
sb.append("(").append(name).append(")");
}
C.List<Object> list = C.newList();
if (null != valueLoader) {
list.append(valueLoader);
} else {
list.append(qualifiers).append(elementLoaders).append(filters);
if (null != mapKey) {
list.append(mapKey);
}
}
if (null != scope) {
list.append(scope.getSimpleName());
}
if (!list.isEmpty()) {
sb.append("@[").append(S.join(", ", list)).append("]");
}
return sb.toString();
}
示例8: adaptFrom
import org.osgl.util.S; //导入依赖的package包/类
public ServerConfig adaptFrom(SqlDbServiceConfig actConfig, act.db.sql.DataSourceConfig dsConfig, SqlDbService svc) {
ServerConfig config = new ServerConfig();
config.setName(svc.id());
config.setDataSourceConfig(adaptFrom(dsConfig, svc));
config.setDdlGenerate(actConfig.ddlGeneratorConfig.create);
config.setDdlRun(actConfig.ddlGeneratorConfig.create);
config.setDdlCreateOnly(!actConfig.ddlGeneratorConfig.drop);
config.setNamingConvention(namingConvention(actConfig));
Set<Class> modelClasses = svc.modelClasses();
if (null != modelClasses && !modelClasses.isEmpty()) {
for (Class modelClass : modelClasses) {
if (LOGGER.isTraceEnabled()) {
LOGGER.trace(S.concat("add model class into Ebean config: ", modelClass.getName()));
}
config.addClass(modelClass);
}
}
return config;
}
示例9: typeDesc
import org.osgl.util.S; //导入依赖的package包/类
private static String typeDesc(BeanSpec spec) {
String root = classDesc(spec.rawType());
List<java.lang.reflect.Type> typeParams = spec.typeParams();
if (typeParams.isEmpty()) {
return root;
}
S.Buffer sb = S.newBuffer("<");
for (java.lang.reflect.Type type : typeParams) {
BeanSpec specx = BeanSpec.of(type, null, spec.injector());
sb.append(typeDesc(specx));
}
sb.append(">");
FastStr str = FastStr.of(root);
str = str.take(str.length() - 1).append(sb.toString()).append(";");
return str.toString();
}
示例10: addSetter
import org.osgl.util.S; //导入依赖的package包/类
private void addSetter(Map.Entry<String, $.T2<String, String>> field) {
String name = field.getKey();
String desc = field.getValue()._1;
String signature = field.getValue()._2;
if (null != signature) {
signature = S.concat("(", signature, ")V");
}
MethodVisitor mv = visitMethod(ACC_PUBLIC, setterName(name), S.concat("(", desc, ")V"), signature, null);
mv.visitCode();
mv.visitVarInsn(ALOAD, 0);
mv.visitVarInsn(loadCode(desc), 1);
mv.visitFieldInsn(PUTFIELD, classDesc, name, desc);
mv.visitInsn(RETURN);
if (_D == desc.hashCode() || _J == desc.hashCode()) {
mv.visitMaxs(3, 3);
} else {
mv.visitMaxs(2, 2);
}
mv.visitEnd();
}
示例11: toString
import org.osgl.util.S; //导入依赖的package包/类
@Override
public String toString() {
C.List<String> keys = C.newList(attributes.keySet()).append(listAttributes.keySet()).sorted();
S.Buffer sb = S.newBuffer("@").append(type.getClassName()).append("(");
for (String key: keys) {
Object v = attributes.get(key);
if (null == v) {
v = listAttributes.get(v);
}
sb.append(key).append("=").append(v).append(", ");
}
if (!keys.isEmpty()) {
sb.delete(sb.length() - 2, sb.length());
}
sb.append(")");
return sb.toString();
}
示例12: resolveWithContextMethodPath
import org.osgl.util.S; //导入依赖的package包/类
public final String resolveWithContextMethodPath(ActContext context) {
String methodPath = context.methodPath();
String path = context.templatePath();
String[] sa = path.split("\\.");
int level = sa.length + 1;
S.Buffer sb;
if (S.notBlank(methodPath)) {
while (--level > 0) {
methodPath = S.beforeLast(methodPath, ".");
}
sb = S.newBuffer(methodPath);
} else {
sb = S.newBuffer();
}
if (!path.startsWith("/")) {
sb.append("/");
}
path = sb.append(path).toString().replace('.', '/');
return resolveTemplatePath(path, context);
}
示例13: handle
import org.osgl.util.S; //导入依赖的package包/类
@Override
public void handle(ActionContext context) {
Object ticket = secureTicketCodec.createTicket(context.session());
H.Format accept = context.accept();
H.Response resp = context.prepareRespForWrite();
resp.contentType(accept.contentType());
String content;
if (H.Format.JSON == accept) {
Map<String, Object> map = C.Map("ticket", ticket);
content = JSON.toJSONString(map);
} else if (H.Format.XML == accept) {
content = S.concat("<?xml version=\"1.0\" ?><ticket>", ticket.toString(), "</ticket>");
} else {
content = ticket.toString();
}
resp.writeContent(content);
}
示例14: urlContext
import org.osgl.util.S; //导入依赖的package包/类
public String urlContext() {
if (null != parent) {
if (S.notBlank(urlContext) && urlContext.length() > 1 && urlContext.startsWith("/")) {
return urlContext;
}
String parentContextPath = parent.urlContext();
if (null == urlContext) {
return parentContextPath;
}
if (null == parentContextPath) {
return urlContext;
}
S.Buffer sb = S.newBuffer(parentContextPath);
if (parentContextPath.endsWith("/")) {
sb.deleteCharAt(sb.length() - 1);
}
if (!urlContext.startsWith("/")) {
sb.append("/");
}
sb.append(urlContext);
return sb.toString();
}
return urlContext;
}
示例15: line
import org.osgl.util.S; //导入依赖的package包/类
private static String line(ActionContext actionContext) {
String cmd = null;
S.Buffer sb = S.buffer();
for (String s : actionContext.paramKeys()) {
if ("cmd".equals(s)) {
cmd = actionContext.paramVal(s);
} else if (s.startsWith("-")) {
String val = actionContext.paramVal(s);
if (S.notBlank(val)) {
val = val.replaceAll("[\n\r]+", "<br/>").trim();
if (val.contains(" ")) {
char quote = val.contains("\"") ? '\'' : '\\';
val = S.wrap(val, quote);
}
if (s.contains(",")) {
s = S.before(s, ",");
}
sb.append(s).append(" ").append(val).append(" ");
}
}
}
E.illegalArgumentIf(null == cmd, "cmd param required");
return S.builder(cmd).append(" ").append(sb.toString()).toString();
}