The Artima Developer Community
Sponsored Link

Agile Buzz Forum
BottomFeeder derived libraries

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
James Robertson

Posts: 29924
Nickname: jarober61
Registered: Jun, 2003

David Buck, Smalltalker at large
BottomFeeder derived libraries Posted: Jul 3, 2006 10:52 AM
Reply to this message Reply

This post originated from an RSS feed registered with Agile Buzz by James Robertson.
Original Post: BottomFeeder derived libraries
Feed Title: Cincom Smalltalk Blog - Smalltalk with Rants
Feed URL: http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml
Feed Description: James Robertson comments on Cincom Smalltalk, the Smalltalk development community, and IT trends and issues in general.
Latest Agile Buzz Posts
Latest Agile Buzz Posts by James Robertson
Latest Posts From Cincom Smalltalk Blog - Smalltalk with Rants

Advertisement

I've made progress on freeing two packages from their dependency on BottomFeeder - PatchFileDelivery and SyndicationHandling. The former is a simple toolset for setting up HTTP based updates to an application. To use it, you have to set up an XML based config file on a server, and have HTTP access to that file. Setting up the file works like this:


defs := OrderedCollection new.
list := #('ParcelFileName/pcl').
names := #('My Application Parcel').
descripts := #('Description of this component').
sizes := list collect: [:each | each asFilename fileSize]. 
allows := #(true).
list do: [:each | | version nm timestamp properties index |
	properties := [CodeReader new readInfoFromFileNamed: each] 
				on: OsError, CodeReader fileFormatSignal
				do: [:ex | ex return: Dictionary new].
	version := properties at: #version.
	nm := properties at: #parcel.
	timestamp := properties at: #timestamp.
	index := list indexOf: each.
	comp := ComponentDefinition
		parcelName: nm
		parcelFilename: (each asFilename tail asString)
		version: version
		releaseDate: timestamp
		descriptiveName: (names at: index).
	comp description: (descripts at: index).
	comp fileSize: (sizes at: index).
	comp allowDynamicLoad: (allows at: index).
	defs add: comp].


That sets up a simple configuration file. You place that in an accessible location (along with the parcel, obviously), and you're ready to go. On the client end, you need to have the UpgradeManager class check for updates. You do that with the #grabRemoteUpgradeDefinitions message. That looks like this:


grabRemoteUpgradeDefinitions
	"try to connect to remote server and get the available updates"

	|  url  defs |
	url := self settings upgradeURL last = $/
		ifTrue: [self settings upgradeURL, self settings upgradeFilename]
		ifFalse: [self settings upgradeURL, '/', self settings upgradeFilename].
	defs := (XMLConfigFile loadFromURL: url).
	(defs isNil or: [defs isEmpty])
		ifTrue: [self patches: #()]
		ifFalse: [| tmps | 
				tmps := defs first.
				tmps do: [:each |
					each oldVersion: each getCurrentlyLoadedVersion].
				self patches: (tmps select: [:each | each couldReplaceLoadedComponent])]

That uses the XMLConfigFile class (in a separate package) to load the update definitions. Those are then checked agains what's actually loaded, and we come up with a list of potential updates. In Bf, that's presented to the user - you could automate it from there. In the UpgradeManager, there's an #upgrade: and #upgradeAll API for doing that.

The other package, Syndication-Handling, is not as cleanly separated yet. There are a few ugly #isDefined checks, but it does load and work independently of Bf. Once you load it, you can see how it works by doing this:


doc := Constructor  
	documentFromURL: 'http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml' 
	forceUpdate: true 
	useMaskedAgent: false.
cls := Constructor determineClassToHandle: doc content.
target := cls objectForData.
feed := cls 
	processDocument: doc content
	from: 'http://www.cincomsmalltalk.com/rssBlog/rssBlogView.xml' 
	into: target.

You'll get back this if you inspect to feed object:

Feed in inspector

That code should work against any version of RSS or Atom out there, and should give you back a FeedList (a collection of feeds) if you hand it OPML or OCS.

Read: BottomFeeder derived libraries

Topic: DabbleDB gets more press Previous Topic   Next Topic Topic: Cartoon Insight

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use