本文整理了Java中com.vmware.xenon.common.Utils.getServiceUiResourcePath()
方法的一些代码示例,展示了Utils.getServiceUiResourcePath()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.getServiceUiResourcePath()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:getServiceUiResourcePath
[英]Compute ui resource path for this service.
If service has defined the custom path on ServiceDocumentDescription userInterfaceResourcePath field that will be used else default UI path will be calculated using service path Eg. for ExampleService default path will be ui/com/vmware/xenon/services/common/ExampleService
[中]计算此服务的ui资源路径。
如果服务已在ServiceDocumentDescription userInterfaceResourcePath字段上定义了将使用的自定义路径,则默认UI路径将使用服务路径计算,例如,服务默认路径将为UI/com/vmware/xenon/services/common/ExampleService
代码示例来源:origin: vmware/admiral
protected void startUiFileContentServices() throws Throwable {
Map<Path, String> pathToURIPath = new HashMap<>();
Path baseResourcePath = Utils.getServiceUiResourcePath(this);
try {
pathToURIPath = discoverUiResources(baseResourcePath, this);
} catch (Throwable e) {
log(Level.WARNING, "Error enumerating UI resources for %s: %s", this.getSelfLink(),
Utils.toString(e));
}
if (pathToURIPath.isEmpty()) {
log(Level.WARNING, "No custom UI resources found for %s", this.getClass().getName());
return;
}
for (Entry<Path, String> e : pathToURIPath.entrySet()) {
String value = e.getValue();
if (value.contains("/META-INF/")) {
continue;
}
Operation post = Operation
.createPost(UriUtils.buildUri(getHost(), value));
RestrictiveFileContentService fcs = new RestrictiveFileContentService(
e.getKey().toFile());
getHost().startService(post, fcs);
}
}
代码示例来源:origin: vmware/xenon
@Test
public void testServiceProvidedUiPathEmpty() {
class MyService extends StatelessService {
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument serviceDocument = new ServiceDocument();
serviceDocument.documentDescription = new ServiceDocumentDescription();
serviceDocument.documentDescription.userInterfaceResourcePath = "";
return serviceDocument;
}
}
assertNull(Utils.getServiceUiResourcePath(new MyService()));
}
代码示例来源:origin: vmware/xenon
@Test
public void testServiceProvidedUiPath() {
String resourcePath = "ui/exampleService";
class MyService extends StatelessService {
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument serviceDocument = new ServiceDocument();
serviceDocument.documentDescription = new ServiceDocumentDescription();
serviceDocument.documentDescription.userInterfaceResourcePath = resourcePath;
return serviceDocument;
}
}
Path path = Paths.get(resourcePath);
assertEquals(path, Utils.getServiceUiResourcePath(new MyService()));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void testServiceProvidedUiPath() {
String resourcePath = "ui/exampleService";
class MyService extends StatelessService {
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument serviceDocument = new ServiceDocument();
serviceDocument.documentDescription = new ServiceDocumentDescription();
serviceDocument.documentDescription.userInterfaceResourcePath = resourcePath;
return serviceDocument;
}
}
Path path = Paths.get(resourcePath);
assertEquals(path, Utils.getServiceUiResourcePath(new MyService()));
}
代码示例来源:origin: vmware/xenon
@Override
public void handleStart(Operation startPost) {
try {
Path baseResourcePath = Utils.getServiceUiResourcePath(this);
Path baseUriPath = Paths.get(getSelfLink());
String prefix = baseResourcePath.toString().replace('\\', '/');
Map<Path, String> pathToURIPath = new HashMap<>();
if (getHost().getState().resourceSandboxFileReference != null) {
getHost().discoverFileResources(this, pathToURIPath, baseUriPath, prefix);
}
if (pathToURIPath.isEmpty()) {
getHost().discoverJarResources(baseResourcePath, this, pathToURIPath, baseUriPath, prefix);
}
if (pathToURIPath.isEmpty()) {
log(Level.WARNING, "No custom UI resources found for %s", this.getClass().getName());
}
for (Entry<Path, String> e : pathToURIPath.entrySet()) {
String value = e.getValue();
Operation post = Operation.createPost(UriUtils.buildUri(getHost(), value));
FileContentService fcs = new FileContentService(e.getKey().toFile());
getHost().startService(post, fcs);
}
} catch (Exception e) {
log(Level.WARNING, "Error enumerating UI resources for %s: %s", this.getSelfLink(),
Utils.toString(e));
}
super.handleStart(startPost);
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void testServiceProvidedUiPathEmpty() {
class MyService extends StatelessService {
@Override
public ServiceDocument getDocumentTemplate() {
ServiceDocument serviceDocument = new ServiceDocument();
serviceDocument.documentDescription = new ServiceDocumentDescription();
serviceDocument.documentDescription.userInterfaceResourcePath = "";
return serviceDocument;
}
}
assertNull(Utils.getServiceUiResourcePath(new MyService()));
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void testServiceUiDefaultPath() {
class MyService extends StatelessService {
}
Service s = new MyService();
s.setHost(new VerificationHost());
Path path = Paths.get(Utils.UI_DIRECTORY_NAME, Utils.buildServicePath(MyService.class));
assertEquals(path, Utils.getServiceUiResourcePath(s));
}
代码示例来源:origin: vmware/xenon
baseUriPath = getBaseUriPath(cpr, s, true);
} else {
Path baseResourcePath = Utils.getServiceUiResourcePath(s);
rootDir = discoverUiResources(baseResourcePath, s, false, pathToURIPath);
baseUriPath = getBaseUriPath(baseResourcePath, s, false);
代码示例来源:origin: vmware/xenon
@Test
public void testServiceUiDefaultPath() {
class MyService extends StatelessService {
}
Service s = new MyService();
s.setHost(new VerificationHost());
Path path = Paths.get(Utils.UI_DIRECTORY_NAME, Utils.buildServicePath(MyService.class));
assertEquals(path, Utils.getServiceUiResourcePath(s));
}
代码示例来源:origin: vmware/xenon
Path baseResourcePath = Utils.getServiceUiResourcePath(s);
Path baseUriPath = Paths.get(AppUiService.SELF_LINK);
String prefix = baseResourcePath.toString().replace('\\', '/');
代码示例来源:origin: com.vmware.xenon/xenon-common
Path baseResourcePath = Utils.getServiceUiResourcePath(s);
Path baseUriPath = Paths.get(AppUiService.SELF_LINK);
String prefix = baseResourcePath.toString().replace('\\', '/');
内容来源于网络,如有侵权,请联系作者删除!