org.onebusaway.transit_data_federation.impl.realtime
Class BlockLocationServiceImpl

java.lang.Object
  extended by org.onebusaway.transit_data_federation.impl.realtime.BlockLocationServiceImpl
All Implemented Interfaces:
BlockVehicleLocationListener, BlockLocationService

@Component
@ManagedResource(value="org.onebusaway.transit_data_federation.impl.realtime:name=BlockLocationServiceImpl")
public class BlockLocationServiceImpl
extends Object
implements BlockLocationService, BlockVehicleLocationListener

Implementation for BlockLocationService. Keeps a recent cache of BlockLocationRecord records for current queries and can access database persisted records for queries in the past.

Author:
bdferris
See Also:
BlockLocationService

Constructor Summary
BlockLocationServiceImpl()
           
 
Method Summary
 long getBlockLocationRecordPersistentStoreAccessCount()
           
 long getLastInsertCount()
           
 long getLastInsertDuration()
          JMX Attributes
 BlockLocation getLocationForBlockInstance(BlockInstance blockInstance, TargetTime time)
          BlockLocationService Interface
 BlockLocation getLocationForBlockInstanceAndScheduledBlockLocation(BlockInstance blockInstance, ScheduledBlockLocation scheduledLocation, long targetTime)
           
 BlockLocation getLocationForVehicleAndTime(org.onebusaway.gtfs.model.AgencyAndId vehicleId, TargetTime targetTime)
           
 Map<org.onebusaway.gtfs.model.AgencyAndId,List<BlockLocation>> getLocationsForBlockInstance(BlockInstance blockInstance, List<Date> times, long currentTime)
           
 List<BlockLocation> getLocationsForBlockInstance(BlockInstance blockInstance, TargetTime time)
          Given a block instance and a target time, determine the vehicle locations at that time using real-time data when available.
 BlockLocation getScheduledLocationForBlockInstance(BlockInstance blockInstance, long targetTime)
          Determines the scheduled vehicle location of a given block instance at the specified time.
 void handleVehicleLocationRecord(VehicleLocationRecord record)
          BlockVehicleLocationListener Interface
 void resetVehicleLocation(org.onebusaway.gtfs.model.AgencyAndId vehicleId)
           
 void setBlockCalendarService(BlockCalendarService blockCalendarService)
           
 void setBlockLocationListeners(List<BlockLocationListener> listeners)
           
 void setBlockLocationRecordCacheWindowSize(int windowSize)
          Controls how far back in time we include records in the BlockLocationRecordCollection for each active trip.
 void setBlockLocationRecordDao(BlockLocationRecordDao blockLocationRecordDao)
           
 void setDistanceAlongBlockLocationInterpolation(boolean distanceAlongBlockLocationInterpolation)
           
 void setPersistBlockLocationRecords(boolean persistBlockLocationRecords)
          Should we persist BlockLocationRecord records to an underlying datastore.
 void setRealTimeHistoryService(RealTimeHistoryService realTimeHistoryService)
           
 void setScheduledBlockLocationService(ScheduledBlockLocationService scheduleBlockLocationService)
           
 void setTransitGraphDao(TransitGraphDao transitGraphDao)
           
 void setVehicleLocationRecordCache(VehicleLocationRecordCache cache)
           
 void start()
          Setup and Teardown
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

BlockLocationServiceImpl

public BlockLocationServiceImpl()
Method Detail

setVehicleLocationRecordCache

public void setVehicleLocationRecordCache(VehicleLocationRecordCache cache)

setBlockLocationRecordDao

public void setBlockLocationRecordDao(BlockLocationRecordDao blockLocationRecordDao)

setTransitGraphDao

public void setTransitGraphDao(TransitGraphDao transitGraphDao)

setScheduledBlockLocationService

public void setScheduledBlockLocationService(ScheduledBlockLocationService scheduleBlockLocationService)

setBlockCalendarService

public void setBlockCalendarService(BlockCalendarService blockCalendarService)

setRealTimeHistoryService

public void setRealTimeHistoryService(RealTimeHistoryService realTimeHistoryService)

setBlockLocationListeners

public void setBlockLocationListeners(List<BlockLocationListener> listeners)

setBlockLocationRecordCacheWindowSize

public void setBlockLocationRecordCacheWindowSize(int windowSize)
Controls how far back in time we include records in the BlockLocationRecordCollection for each active trip.

Parameters:
windowSize - in seconds

setPersistBlockLocationRecords

public void setPersistBlockLocationRecords(boolean persistBlockLocationRecords)
Should we persist BlockLocationRecord records to an underlying datastore. Useful if you wish to query trip status for historic analysis.

Parameters:
persistTripTimePredictions -

setDistanceAlongBlockLocationInterpolation

public void setDistanceAlongBlockLocationInterpolation(boolean distanceAlongBlockLocationInterpolation)
Parameters:
distanceAlongBlockLocationInterpolation -

getLastInsertDuration

@ManagedAttribute
public long getLastInsertDuration()
JMX Attributes


getLastInsertCount

@ManagedAttribute
public long getLastInsertCount()

getBlockLocationRecordPersistentStoreAccessCount

@ManagedAttribute
public long getBlockLocationRecordPersistentStoreAccessCount()

start

@PostConstruct
public void start()
Setup and Teardown


stop

@PreDestroy
public void stop()

handleVehicleLocationRecord

public void handleVehicleLocationRecord(VehicleLocationRecord record)
BlockVehicleLocationListener Interface

Specified by:
handleVehicleLocationRecord in interface BlockVehicleLocationListener

resetVehicleLocation

public void resetVehicleLocation(org.onebusaway.gtfs.model.AgencyAndId vehicleId)
Specified by:
resetVehicleLocation in interface BlockVehicleLocationListener

getLocationForBlockInstance

public BlockLocation getLocationForBlockInstance(BlockInstance blockInstance,
                                                 TargetTime time)
BlockLocationService Interface

Specified by:
getLocationForBlockInstance in interface BlockLocationService
Parameters:
blockInstance - the block instance to query
time - the target time (Unix-time)
Returns:
the block location, or null if the block instance is not active at the specified time

getLocationForBlockInstanceAndScheduledBlockLocation

public BlockLocation getLocationForBlockInstanceAndScheduledBlockLocation(BlockInstance blockInstance,
                                                                          ScheduledBlockLocation scheduledLocation,
                                                                          long targetTime)
Specified by:
getLocationForBlockInstanceAndScheduledBlockLocation in interface BlockLocationService

getLocationsForBlockInstance

public List<BlockLocation> getLocationsForBlockInstance(BlockInstance blockInstance,
                                                        TargetTime time)
Description copied from interface: BlockLocationService
Given a block instance and a target time, determine the vehicle locations at that time using real-time data when available.

Specified by:
getLocationsForBlockInstance in interface BlockLocationService
Parameters:
blockInstance - the trip instance to query
time - TODO
Returns:
the block locations, or empty if no block locations are active at the specified time

getLocationsForBlockInstance

public Map<org.onebusaway.gtfs.model.AgencyAndId,List<BlockLocation>> getLocationsForBlockInstance(BlockInstance blockInstance,
                                                                                                   List<Date> times,
                                                                                                   long currentTime)
Specified by:
getLocationsForBlockInstance in interface BlockLocationService

getScheduledLocationForBlockInstance

public BlockLocation getScheduledLocationForBlockInstance(BlockInstance blockInstance,
                                                          long targetTime)
Description copied from interface: BlockLocationService
Determines the scheduled vehicle location of a given block instance at the specified time.

Specified by:
getScheduledLocationForBlockInstance in interface BlockLocationService
Returns:
the scheduled location of a particular block instance, or null if not active at the specified time

getLocationForVehicleAndTime

public BlockLocation getLocationForVehicleAndTime(org.onebusaway.gtfs.model.AgencyAndId vehicleId,
                                                  TargetTime targetTime)
Specified by:
getLocationForVehicleAndTime in interface BlockLocationService


Copyright © 2012 OneBusAway. All Rights Reserved.