Skip to content

Commit

Permalink
buglabs-osgi: minor code cleanup in gps and ws servlet.
Browse files Browse the repository at this point in the history
  • Loading branch information
kgilmer committed Jul 7, 2011
1 parent 7cd7643 commit d98e9fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
Expand Up @@ -81,17 +81,22 @@ public class GPSModlet extends AbstractBUGModlet implements IGPSModuleControl, P

private ServiceRegistration moduleReg;

protected static final String PROPERTY_MODULE_NAME = "moduleName";
protected static final String PROPERTY_IOX = "IOX";
protected static final String PROPERTY_GPS_FIX = "GPS Fix";
protected static final String PROPERTY_ANTENNA = "Antenna";
protected static final String PROPERTY_ANTENNA_PASSIVE = "Passive";
protected static final String PROPERTY_ANTENNA_ACTIVE = "Active";

public static final String MODULE_ID = "0001";

/**
* Service property that defines active Antenna type.
*/
private static final String EXTERNAL_ANTENNA_PROPERTY = "gps.antenna.external";

/**
* Number of millis to wait before checking the GPS sync status.
*/
private static final long GPS_STATUS_SCAN_INTERVAL = 5000;

private NMEASentenceProvider nmeaProvider;
private GPSControl gpsControl;

Expand Down Expand Up @@ -149,12 +154,13 @@ public void start() throws Exception {
registerService(PublicWSProvider.class.getName(), this, null);

timer = new Timer();
timer.schedule(new GPSFIXLEDStatusTask(this, getLog()), 500, 5000);
timer.schedule(new GPSFIXLEDStatusTask(this, getLog()), 500, GPS_STATUS_SCAN_INTERVAL);

registerService(IPositionProvider.class.getName(), this, createBasicServiceProperties());
context.addServiceListener(nmeaProvider, "(|(" + Constants.OBJECTCLASS + "=" + INMEASentenceSubscriber.class.getName() + ") (" + Constants.OBJECTCLASS + "="
+ IPositionSubscriber.class.getName() + "))");
context.addServiceListener(nmeaProvider, FilterUtil.generateServiceFilter(INMEASentenceSubscriber.class.getName(), IPositionSubscriber.class.getName()));

context.addServiceListener(nmeaProvider, FilterUtil.generateServiceFilter(
INMEASentenceSubscriber.class.getName(),
IPositionSubscriber.class.getName()));
}

private Dictionary createBasicServiceProperties() {
Expand Down
Expand Up @@ -45,6 +45,7 @@

import com.buglabs.services.ws.PublicWSProvider;
import com.buglabs.services.ws.PublicWSProvider2;
import com.buglabs.util.osgi.FilterUtil;
import com.buglabs.util.osgi.LogServiceUtil;
import com.buglabs.util.osgi.OSGiServiceLoader;

Expand Down Expand Up @@ -78,8 +79,10 @@ public AbstractWSServlet(BundleContext context, Map<String, PublicWSProvider> se
if (!listenerRegistered) {
listenerRegistered = true;
addExistingServices(context, serviceMap);
context.addServiceListener(this, "(|(" + Constants.OBJECTCLASS + "=" + PublicWSProvider2.class.getName() + ") (" + Constants.OBJECTCLASS + "="
+ PublicWSProvider.class.getName() + "))");
context.addServiceListener(this, FilterUtil.generateServiceFilter(
PublicWSProvider2.class.getName(),
PublicWSProvider.class.getName()
));
}
} catch (Exception e) {
//Since our filter does not change, this should never occur.
Expand Down

0 comments on commit d98e9fd

Please sign in to comment.