Automatic extension reload on filechange

Post here your suggestions for new possible features in SmartFoxServer.

Moderators: Lapo, Bax

duke
Posts: 31
Joined: 16 Apr 2009, 11:23

Automatic extension reload on filechange

Postby duke » 17 May 2009, 23:16

What would be great is if an active extension (one that is loaded into a currently active zone/room) would reload itself if it's file is changed. This would save navigating to the zone, then reloading that extension or series of extensions and would speed up development time! Alternatively, is there a command I can send directly to SFS to reload an extension?
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 18 May 2009, 05:36

Duke,
this feature already exists in SmartFoxServer since version 1.5.x
You can activate it by adding <AutoReloadExtensions>true </AutoReloadExtensions> under the <ServerSetup> node to activate it globally.

Then you have to add the same code in each <Zone> definition where you want the autoreload to be activated.
NOTE: we highly recommend to disable it globally on production servers.
Lapo
--
gotoAndPlay()
...addicted to flash games
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 19 May 2009, 00:58

Hi Lapo,

This does not seem to work for me. I tested it just by changing the traces in the destroy and init methods of an extension but they are not changed at all when I saved the file.

I do get the message the extension is reloaded but the traces in those methods only shows the original message as during start up. The change only happens after I restart the server.

By the way I am using SFS 1.6.6 PRO with Java extensions.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 19 May 2009, 03:58

Make sure you don't have the javaExtension/ folder in your classpath
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 May 2009, 02:30

Hi Lapo,

I tried removing the javaExtension folder from the classpath as well as the physical folder itself but it doesn't seem to work.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 May 2009, 06:36

Make sure you have followed these steps:
http://www.smartfoxserver.com/docs/docP ... ons.htm#9a

Also remember that the server monitors your main Extension class (the one extending AbstractExtension) so if you don't overwrite that together with the other classes the auto-reloading won't trigger.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 May 2009, 06:51

Hi Lapo,

I have followed the steps on AutoReloadExtensions and manage to point the classpath to my bin folder. But I am confused at these lines:

Make sure that the javaExtensions/ folder is not comprised in your classpath. By default SmartFoxServer includes this folder in the classpath so that all extension code is loaded at boot-time by the JVM system class loader. While this can be useful for sharing classes across multiple extensions (e.g. Singletons etc...) it will prevent dynamic reloading of the classes. If you remove the javaExtensions/ folder from the classpath, SmartFoxServer will use a separate class loader for each Extension and allowing dynamic reloading.

NOTE: Dynamic reloading does not work outside of the javaExtensions/ folder and does not support .jar files


So I don't include the javaExtensions folder in my classpath but anything out of the javaExtensions folder won't allow dynamic reloading? :? It sounds contradicting in my understanding. Please correct me.
User avatar
Lapo
Site Admin
Posts: 23008
Joined: 21 Mar 2005, 09:50
Location: Italy

Postby Lapo » 22 May 2009, 06:55

javaExtensions/ is the root folder for your extensions.

As explained in the docs, if the folder is added to the classpath dynamic reloading won't work. If you remove it, it will.
The reason is the way class loaders work in the JVM.
Last edited by Lapo on 22 May 2009, 07:04, edited 1 time in total.
Lapo

--

gotoAndPlay()

...addicted to flash games
User avatar
darnpunk
Posts: 229
Joined: 22 Jun 2007, 02:58
Location: SG

Postby darnpunk » 22 May 2009, 07:02

Hi Lapo,

Thanks for the explanation. It is working now :D

Return to “Features Wish List”

Who is online

Users browsing this forum: No registered users and 21 guests