// Get the remote component server using the supplied URI
RemoteComponentServer remoteComponentServer = new RemoteComponentServer(URI.create(configResourceLocation));
ComponentServer componentServer = remoteComponentServer.getComponentServer();
// Attempt to build a tool context of the specified type
ToolContext toolContext;
try {
toolContext = toolContextClazz.newInstance();
} catch (Throwable t) {
return null;
}
// Populate the tool context from the remote component server
for (MetaProperty<?> metaProperty : toolContext.metaBean().metaPropertyIterable()) {
if (!metaProperty.name().equals("contextManager")) {
try {
ComponentInfo componentInfo = getComponentInfo(componentServer, classifierChain, metaProperty.propertyType());
if (componentInfo == null) {
s_logger.warn("Unable to populate tool context '" + metaProperty.name() +
"', no appropriate component found on the server");
continue;
}
if (ViewProcessor.class.equals(componentInfo.getType())) {
final JmsConnector jmsConnector = createJmsConnector(componentInfo);
final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor(new NamedThreadFactory("rvp"));
ViewProcessor vp = new RemoteViewProcessor(componentInfo.getUri(), jmsConnector, scheduler);
toolContext.setViewProcessor(vp);
toolContext.setContextManager(new Closeable() {
@Override
public void close() throws IOException {
scheduler.shutdownNow();
jmsConnector.close();
}