You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by cz...@apache.org on 2007/09/19 10:53:59 UTC
svn commit: r577203 - in
/incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl:
AbstractRepositoryEventHandler.java EventHelper.java
Author: cziegeler
Date: Wed Sep 19 01:53:58 2007
New Revision: 577203
URL: http://svn.apache.org/viewvc?rev=577203&view=rev
Log:
Use new sling.id for the application instance id.
Modified:
incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
Modified: incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java?rev=577203&r1=577202&r2=577203&view=diff
==============================================================================
--- incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java (original)
+++ incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/AbstractRepositoryEventHandler.java Wed Sep 19 01:53:58 2007
@@ -40,7 +40,6 @@
import org.osgi.service.event.Event;
import org.osgi.service.event.EventAdmin;
import org.osgi.service.event.EventHandler;
-import org.osgi.service.prefs.PreferencesService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -70,9 +69,6 @@
/** @scr.reference */
protected EventAdmin eventAdmin;
- /** @scr.reference */
- protected PreferencesService preferences;
-
/** Our application id. */
protected String applicationId;
@@ -92,7 +88,8 @@
*/
protected void activate(final ComponentContext context)
throws RepositoryException {
- this.applicationId = EventHelper.getApplicationId(this.preferences);
+ // FIXME - We should rather use a provided constant for the sling id
+ this.applicationId = context.getBundleContext().getProperty("sling.id");
this.cleanupPeriod = (Integer)context.getProperties().get(CONFIG_PROPERTY_CLEANUP_PERIOD);
this.startSession();
}
Modified: incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/EventHelper.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/EventHelper.java?rev=577203&r1=577202&r2=577203&view=diff
==============================================================================
--- incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/EventHelper.java (original)
+++ incubator/sling/trunk/event/src/main/java/org/apache/sling/event/impl/EventHelper.java Wed Sep 19 01:53:58 2007
@@ -18,13 +18,6 @@
*/
package org.apache.sling.event.impl;
-import java.util.UUID;
-
-import org.osgi.service.prefs.BackingStoreException;
-import org.osgi.service.prefs.Preferences;
-import org.osgi.service.prefs.PreferencesService;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
/**
* Helper class defining some constants and providing support for identifying nodes in a cluster.
@@ -44,32 +37,4 @@
public static final String EVENT_NODE_TYPE = "event:Event";
public static final String JOBS_NODE_TYPE = "event:Jobs";
public static final String JOB_NODE_TYPE = "event:Job";
-
- public static final String APPLICATION_ID_PREFERENCE = "event.application.id";
-
- /** Default log. */
- protected static final Logger logger = LoggerFactory.getLogger(EventHelper.class);
-
- public static synchronized String getApplicationId(PreferencesService service) {
- final Preferences prefs = service.getSystemPreferences();
- String appId = prefs.get(APPLICATION_ID_PREFERENCE, null);
- if ( appId == null ) {
- final UUID uuid = UUID.randomUUID();
- appId = uuid.toString();
- if ( logger.isInfoEnabled() ) {
- logger.info("Generating new application id " + appId);
- }
- prefs.put(APPLICATION_ID_PREFERENCE, appId);
- try {
- prefs.flush();
- } catch (BackingStoreException e) {
- // FIXME - we ignore this for now
- logger.error("Exception during storing of preferences.", e);
- }
- }
- if ( logger.isInfoEnabled() ) {
- logger.info("Using application id " + appId);
- }
- return appId;
- }
}