String smallIcon = attributes.getValue("small-icon");
String largeIcon = attributes.getValue("large-icon");
String clazz = attributes.getValue("class");
String bookmark = attributes.getValue("bookmark");
Processor processor = (Processor)processorMap.get(uri);
ProcessorDescriptor processorDescriptor = (ProcessorDescriptor)processorDescriptors.get(uri);
try {
if ( processor == null ) {
processor = (Processor)processorClassLoader.loadClass(clazz).getConstructor(new Class[0]).newInstance(new Object[0]);
added = true;
modified = true;
}
if ( processorDescriptor == null ) {
processorDescriptor = new ProcessorDescriptor(uri);
modified = true;
}
if ( processorName == null ) processorName = uri.toString();
if ( processorDescriptor.getName() == null || !processorDescriptor.getName().equals(processorName) ) {
processorDescriptor.setName(processorName);
modified = true;
}
if ( descriptionKey == null ) {
descriptionKey = "processorManager/noProcessorDescriptionAvailable";
}
DefaultMessage description = null;
if ( processorDescriptor.getDescription() == null || !processorDescriptor.getDescription().getId().equals(descriptionKey) ) {
description = new DefaultMessage(descriptionKey);
processorDescriptor.setDescription(description);
modified = true;
}
if ( processorDescriptor.getProcessor() != processor ) {
processorDescriptor.setProcessor(processor);
modified = true;
}
URI smallIconUri = SMALL_DEFAULT_ICON, largeIconUri = LARGE_DEFAULT_ICON;
if ( smallIcon != null ) smallIconUri = new URIValue(smallIcon);
if ( largeIcon != null ) largeIconUri = new URIValue(largeIcon);
if ( processorDescriptor.getSmallIcon() == null || !processorDescriptor.getSmallIcon().equals(smallIconUri) ) {
processorDescriptor.setSmallIcon(smallIconUri);
modified = true;
}
if ( processorDescriptor.getLargeIcon() == null || !processorDescriptor.getLargeIcon().equals(largeIconUri) ) {
processorDescriptor.setLargeIcon(largeIconUri);
modified = true;
}
if ( bookmark != null ) {
boolean isBookmark = Boolean.valueOf(bookmark).booleanValue();
if ( processorDescriptor.isBookmark() != isBookmark ) {
processorDescriptor.setBookmark(isBookmark);
modified = true;
}
}
if ( processor instanceof ConfigurableProcessor && configURI != null ) {
if ( !configURI.startsWith("/") ) {
configURI = applicationUri.toString() + configURI;
}
URI configurationUri = new URIValue(configURI);
if ( processorDescriptor.getConfiguration() == null || !processorDescriptor.getConfiguration().equals(configurationUri) ) {
logger.log(Level.FINE, "Configuring processor with config-URI=" + configURI);
processorDescriptor.setConfiguration(configurationUri);
StreamableValue config = (StreamableValue)Projector.getRepository().getResource(configurationUri, Projector.getCredentials());
((ConfigurableProcessor)processor).configure(config);
// listen for configuration changes
Subscriber subscriber = new ConfigurationListener();
Projector.getRepository().subscribe("Update", configurationUri, 0, subscriber, Projector.getCredentials());