本文整理了Java中com.vmware.xenon.common.Utils.registerKind()
方法的一些代码示例,展示了Utils.registerKind()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.registerKind()
方法的具体详情如下:
包路径:com.vmware.xenon.common.Utils
类名称:Utils
方法名:registerKind
[英]Registers mapping between a type and document kind string the runtime will use for all services with that state type
[中]注册运行时将用于具有该状态类型的所有服务的类型和文档种类字符串之间的映射
代码示例来源:origin: vmware/admiral
@SuppressWarnings("unchecked")
private static Class<? extends ServiceDocument> getTypeFromKind(String documentKind) {
// TODO: how to find class?
// Check if kind was registered
Class<?> clazz = Utils.getTypeFromKind(documentKind);
if (clazz == null) {
String className = documentKind.replace(':', '.');
while (true) {
try {
clazz = Class.forName(className);
break;
} catch (ClassNotFoundException e) {
int i = className.lastIndexOf('.');
if (i == -1) {
logger.warning("State type not found for " + documentKind);
return null;
}
// Check if inner class, replace last '.' with '$'
StringBuilder sb = new StringBuilder(className);
sb.setCharAt(i, '$');
className = sb.toString();
}
}
// Register kind
Utils.registerKind(clazz, documentKind);
}
return (Class<? extends ServiceDocument>) clazz;
}
代码示例来源:origin: vmware/admiral
private void addTable(TableDescription td) {
Objects.requireNonNull(td.host, "Missing host");
Objects.requireNonNull(td.factoryLink, "Missing factoryLink");
Objects.requireNonNull(td.documentKind, "Missing documentKind");
Objects.requireNonNull(td.stateType, "Missing stateType");
Objects.requireNonNull(td.sdd, "Missing sdd (ServiceDocumentDescription)");
if (td.tableName == null || td.tableName.isEmpty()) {
td.tableName = toTableName(td.stateType, td.factoryLink);
Objects.requireNonNull(td.tableName, "Missing tableName");
}
if (this.tableNames.contains(td.tableName)) {
logger.severe(String.format("Factory already registered for table %s", td.tableName));
}
// Skip registering document kinds that is ServiceDocument, some bootstrap services use
// it as state type
if (!ServiceDocument.class.equals(td.stateType)) {
if (this.tableDescPerDocumentKind.containsKey(td.documentKind)) {
logger.warning(String.format("Factory already registered for document kind %s: %s",
td.documentKind,
tableDescPerDocumentKind.get(td.documentKind).factoryLink));
}
this.tableDescPerDocumentKind.put(td.documentKind, td);
}
this.tableNames.add(td.tableName);
this.tableDescPerFactoryLink.put(td.factoryLink, td);
Utils.registerKind(td.stateType, td.documentKind);
}
代码示例来源:origin: com.vmware.photon.controller/photon-model
public static void registerCustomDeserializer() {
// Register types that are used with polymorphism
Utils.registerKind(ComputeState.class, Utils.toDocumentKind(ComputeState.class));
Utils.registerKind(NetworkInterfaceState.class,
Utils.toDocumentKind(NetworkInterfaceState.class));
// Register custom mapper to handle polymorphic fields
Utils.registerCustomJsonMapper(LoadBalancerStateExpanded.class, new JsonMapper((b) -> {
b.registerTypeAdapter(ResourceState.class, new ResourceStateDeserializer());
b.registerTypeAdapter(ComputeState.class, new DerivedResourceStateDeserializer());
b.registerTypeAdapter(NetworkInterfaceState.class,
new DerivedResourceStateDeserializer());
}));
}
}
代码示例来源:origin: vmware/xenon
@Before
public void setUp() {
CommandLineArgumentParser.parseFromProperties(this);
Utils.registerKind(ExampleServiceState.class, CUSTOM_EXAMPLE_SERVICE_KIND);
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Before
public void setUp() {
CommandLineArgumentParser.parseFromProperties(this);
Utils.registerKind(ExampleServiceState.class, CUSTOM_EXAMPLE_SERVICE_KIND);
}
代码示例来源:origin: vmware/xenon
@Test
public void registerKind() {
String kindBefore = Utils.buildKind(ExampleServiceState.class);
String newKind = "e";
Utils.registerKind(ExampleServiceState.class, newKind);
String kindAfter = Utils.buildKind(ExampleServiceState.class);
assertEquals(newKind, kindAfter);
Utils.registerKind(ExampleServiceState.class, kindBefore);
kindAfter = Utils.buildKind(ExampleServiceState.class);
assertEquals(kindBefore, kindAfter);
Class<?> stateClass = Utils.getTypeFromKind(kindAfter);
assertEquals(stateClass.getCanonicalName(), ExampleServiceState.class.getCanonicalName());
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Test
public void registerKind() {
String kindBefore = Utils.buildKind(ExampleServiceState.class);
String newKind = "e";
Utils.registerKind(ExampleServiceState.class, newKind);
String kindAfter = Utils.buildKind(ExampleServiceState.class);
assertEquals(newKind, kindAfter);
Utils.registerKind(ExampleServiceState.class, kindBefore);
kindAfter = Utils.buildKind(ExampleServiceState.class);
assertEquals(kindBefore, kindAfter);
Class<?> stateClass = Utils.getTypeFromKind(kindAfter);
assertEquals(stateClass.getCanonicalName(), ExampleServiceState.class.getCanonicalName());
}
代码示例来源:origin: vmware/xenon
@Override
public void initializeHost(VerificationHost host) throws Exception {
try {
// create a xenon service host housing just the user authz rules
this.externalAuthHost = createHost();
ServiceHost.Arguments args = VerificationHost.buildDefaultServiceHostArguments(0);
VerificationHost.initialize(this.externalAuthHost, args);
this.externalAuthHost.setAuthorizationService(new AuthorizationContextService());
this.externalAuthHost.setAuthorizationEnabled(true);
this.externalAuthHost.start();
this.externalAuthHost.setSystemAuthorizationContext();
// create two users
this.userServiceJane = createUsers(this.externalAuthHost, USER_JANE, USER_JANE_EMAIL);
this.userServiceJohn = createUsers(this.externalAuthHost, USER_JOHN, USER_JOHN_EMAIL);
this.externalAuthHost.resetAuthorizationContext();
// start test verification host with an external auth provider
args = VerificationHost.buildDefaultServiceHostArguments(0);
args.authProviderHostUri = this.externalAuthHost.getUri().toString();
args.isAuthorizationEnabled = true;
VerificationHost.initialize(this.host, args);
Utils.registerKind(UserService.UserState.class, Utils.buildKind(UserService.UserState.class));
} catch (Throwable e) {
throw new Exception(e);
}
}
代码示例来源:origin: com.vmware.xenon/xenon-common
@Override
public void initializeHost(VerificationHost host) throws Exception {
try {
// create a xenon service host housing just the user authz rules
this.externalAuthHost = createHost();
ServiceHost.Arguments args = VerificationHost.buildDefaultServiceHostArguments(0);
VerificationHost.initialize(this.externalAuthHost, args);
this.externalAuthHost.setAuthorizationService(new AuthorizationContextService());
this.externalAuthHost.setAuthorizationEnabled(true);
this.externalAuthHost.start();
this.externalAuthHost.setSystemAuthorizationContext();
// create two users
this.userServiceJane = createUsers(this.externalAuthHost, USER_JANE, USER_JANE_EMAIL);
this.userServiceJohn = createUsers(this.externalAuthHost, USER_JOHN, USER_JOHN_EMAIL);
this.externalAuthHost.resetAuthorizationContext();
// start test verification host with an external auth provider
args = VerificationHost.buildDefaultServiceHostArguments(0);
args.authProviderHostUri = this.externalAuthHost.getUri().toString();
args.isAuthorizationEnabled = true;
VerificationHost.initialize(this.host, args);
Utils.registerKind(UserService.UserState.class, Utils.buildKind(UserService.UserState.class));
} catch (Throwable e) {
throw new Exception(e);
}
}
代码示例来源:origin: vmware/xenon
@After
public void tearDown() throws InterruptedException {
this.expectFailure = false;
Utils.registerKind(ExampleServiceState.class,
Utils.toDocumentKind(ExampleServiceState.class));
LuceneDocumentIndexService
.setImplicitQueryResultLimit(LuceneDocumentIndexService.DEFAULT_QUERY_RESULT_LIMIT);
this.replicationFactor = 0;
TestXenonConfiguration.restore();
if (this.host == null) {
return;
}
if (this.host.isRemotePeerTest()) {
try {
this.host.logNodeProcessLogs(this.host.getNodeGroupMap().keySet(),
ServiceUriPaths.PROCESS_LOG);
} catch (Throwable e) {
this.host.log("Failure retrieving process logs: %s", Utils.toString(e));
}
try {
this.host.logNodeManagementState(this.host.getNodeGroupMap().keySet());
} catch (Throwable e) {
this.host.log("Failure retrieving management state: %s", Utils.toString(e));
}
}
this.host.tearDownInProcessPeers();
this.host.toggleNegativeTestMode(false);
this.host.tearDown();
this.host = null;
}
代码示例来源:origin: vmware/xenon
Utils.registerKind(ExampleServiceState.class,
Utils.toDocumentKind(ExampleServiceState.class));
代码示例来源:origin: com.vmware.xenon/xenon-common
Utils.registerKind(ExampleServiceState.class,
Utils.toDocumentKind(ExampleServiceState.class));
代码示例来源:origin: com.vmware.xenon/xenon-common
@After
public void tearDown() throws InterruptedException {
this.expectFailure = false;
Utils.registerKind(ExampleServiceState.class,
Utils.toDocumentKind(ExampleServiceState.class));
LuceneDocumentIndexService
内容来源于网络,如有侵权,请联系作者删除!