- Provides an alternative storage backend to XML in the ConfigurationService implementation which uses Properties for the sake for better execution speed and garbage collection behavior.

- Implements batch configuration property modifications which allow a caller to modify a set of properties with a single saving of the configuration file.
cusax-fix
Lyubomir Marinov 17 years ago
parent e1d01dd9a0
commit 19f509b652

@ -13,31 +13,31 @@
/**
* @author Emil Ivov
* @author Lubomir Marinov
*/
public class ConfigurationActivator
implements BundleActivator
{
/**
* The current bundle context
*/
public static BundleContext bundleContext;
private final Logger logger = Logger.getLogger(ConfigurationServiceImpl.class);
private ConfigurationServiceImpl impl = new ConfigurationServiceImpl();
private final Logger logger
= Logger.getLogger(ConfigurationServiceImpl.class);
private final ConfigurationServiceImpl impl
= new ConfigurationServiceImpl();
/**
* Starts the configuration service
*
* @param bundleContext the BundleContext as provided from the osgi
* framework.
* @throws Exception if anything goes wrong
*
* @param bundleContext
* the BundleContext as provided from the OSGi framework.
* @throws Exception
* if anything goes wrong
*/
public void start(BundleContext bContext) throws Exception
public void start(BundleContext bundleContext)
throws Exception
{
logger.debug("Service Impl: " + getClass().getName() + " [ STARTED ]");
ConfigurationActivator.bundleContext = bContext;
impl.start();
impl.start(bundleContext);
bundleContext.registerService(ConfigurationService.class.getName(),
impl,
@ -48,12 +48,13 @@ public void start(BundleContext bContext) throws Exception
/**
* Causes the configuration service to store the properties object and
* unregisters the configuration servcice.
* unregisters the configuration service.
*
* @param bundlecontext BundleContext
* @param bundleContext BundleContext
* @throws Exception
*/
public void stop(BundleContext bundlecontext) throws Exception
public void stop(BundleContext bundleContext)
throws Exception
{
logger.logEntry();
impl.stop();

@ -491,7 +491,6 @@ private void saveNotification( String eventType,
configService.setProperty(
eventTypeNodeName + ".active",
Boolean.toString(isActive));
return;
}
@ -510,6 +509,8 @@ private void saveNotification( String eventType,
actionTypeNodeName = actionTypeRootPropName;
}
Map<String, Object> configProperties = new HashMap<String, Object>();
// If we didn't find the given actionType in the configuration we save
// it here.
if(actionTypeNodeName == null)
@ -518,7 +519,7 @@ private void saveNotification( String eventType,
+ ".actionType"
+ Long.toString(System.currentTimeMillis());
configService.setProperty(actionTypeNodeName, actionType);
configProperties.put(actionTypeNodeName, actionType);
}
if(actionHandler instanceof SoundNotificationHandler)
@ -526,19 +527,19 @@ private void saveNotification( String eventType,
SoundNotificationHandler soundHandler
= (SoundNotificationHandler) actionHandler;
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".soundFileDescriptor",
soundHandler.getDescriptor());
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".loopInterval",
soundHandler.getLoopInterval());
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".enabled",
Boolean.toString(isActive));
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".default",
Boolean.toString(isDefault));
}
@ -547,15 +548,15 @@ else if(actionHandler instanceof PopupMessageNotificationHandler)
PopupMessageNotificationHandler messageHandler
= (PopupMessageNotificationHandler) actionHandler;
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".defaultMessage",
messageHandler.getDefaultMessage());
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".enabled",
Boolean.toString(isActive));
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".default",
Boolean.toString(isDefault));
}
@ -564,15 +565,15 @@ else if(actionHandler instanceof LogMessageNotificationHandler)
LogMessageNotificationHandler logMessageHandler
= (LogMessageNotificationHandler) actionHandler;
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".logType",
logMessageHandler.getLogType());
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".enabled",
Boolean.toString(isActive));
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".default",
Boolean.toString(isDefault));
}
@ -581,18 +582,21 @@ else if(actionHandler instanceof CommandNotificationHandler)
CommandNotificationHandler commandHandler
= (CommandNotificationHandler) actionHandler;
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".commandDescriptor",
commandHandler.getDescriptor());
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".enabled",
Boolean.toString(isActive));
configService.setProperty(
configProperties.put(
actionTypeNodeName + ".default",
Boolean.toString(isDefault));
}
if (configProperties.size() > 0)
configService.setProperties(configProperties);
}
/**

@ -517,6 +517,9 @@ public void storeAccount(ProtocolProviderFactory factory,
}
}
Map<String, Object> configurationProperties
= new HashMap<String, Object>();
// Create a unique node name of the properties node that will contain
// this account's properties.
if (accountNodeName == null)
@ -525,13 +528,13 @@ public void storeAccount(ProtocolProviderFactory factory,
// set a value for the persistent node so that we could later
// retrieve it as a property
configurationService.setProperty(factoryPackage // prefix
configurationProperties.put(factoryPackage // prefix
+ "." + accountNodeName, accountNodeName);
// register the account in the configuration service.
// we register all the properties in the following hierarchy
//net.java.sip.communicator.impl.protocol.PROTO_NAME.ACC_ID.PROP_NAME
configurationService.setProperty(factoryPackage// prefix
configurationProperties.put(factoryPackage// prefix
+ "." + accountNodeName // node name for the account id
+ "." + ProtocolProviderFactory.ACCOUNT_UID, // propname
accountID.getAccountUniqueID()); // value
@ -549,12 +552,15 @@ public void storeAccount(ProtocolProviderFactory factory,
if (property.equals(ProtocolProviderFactory.PASSWORD))
value = new String(Base64.encode(value.getBytes()));
configurationService.setProperty(factoryPackage // prefix
+ "." + accountNodeName // a uniew node name for the account id
configurationProperties.put(factoryPackage // prefix
+ "." + accountNodeName // a unique node name for the account id
+ "." + property, // propname
value); // value
}
if (configurationProperties.size() > 0)
configurationService.setProperties(configurationProperties);
logger.debug("Stored account for id " + accountID.getAccountUniqueID()
+ " for package " + factoryPackage);
}

@ -77,6 +77,9 @@ public void setProperty(String propertyName,
boolean isSystem)
throws PropertyVetoException;
public void setProperties(Map<String, Object> properties)
throws PropertyVetoException;
/**
* Returns the value of the property with the specified name or null if no
* such property exists.

@ -21,18 +21,19 @@ public class PropertyVetoException
* A PropertyChangeEvent describing the vetoed change.
* @serial
*/
private PropertyChangeEvent evt;
private final PropertyChangeEvent evt;
/**
* Constructs a <tt>PropertyVetoException</tt> with a
* detailed message.
*
* @param mess Descriptive message
* @param message Descriptive message
* @param evt A PropertyChangeEvent describing the vetoed change.
*/
public PropertyVetoException(String mess, PropertyChangeEvent evt)
public PropertyVetoException(String message, PropertyChangeEvent evt)
{
super(mess);
super(message);
this.evt = evt;
}

Loading…
Cancel
Save