You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
|
May
(20) |
Jun
(46) |
Jul
|
Aug
|
Sep
(1) |
Oct
|
Nov
|
Dec
|
---|---|---|---|---|---|---|---|---|---|---|---|---|
2006 |
Jan
|
Feb
|
Mar
(86) |
Apr
(77) |
May
(21) |
Jun
(11) |
Jul
(16) |
Aug
(3) |
Sep
|
Oct
|
Nov
|
Dec
|
2011 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2013 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
(48) |
Oct
(1) |
Nov
(4) |
Dec
|
From: Baleno <tb...@wr...> - 2006-05-23 02:47:09
|
If it is possible to edit the files then they should be visible. If they are going to be binary then hidden won't be a bad idea. Tom ---------- Original Message ----------- From: Snowdog <sn...@ga...> To: ope...@li... Sent: Mon, 22 May 2006 13:14:54 -0700 Subject: [Openrpg2 dev] A matter of preferences > Just wanted to shoot this out to the rest of you for some feedback. > Should the preferences/settings for openrpg follow standard unix > convention and reside in a hidden directory in the users home dir (ie > '.openrpg2' ) or should the directory be visible (id. 'openrpg2') > > Personally I'm for using the stealth version and sticking with > convention. User files (like the gametrees in whatever form they end up > being) may/may not be in this directory. Primarily this is for the > OpenRPG cache and preferences/settings that need to be retained on a > per-user basis. > > opinions? > --Snowdog > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo > http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 > _______________________________________________ > Openrpg-v2-dev mailing list > Ope...@li... > https://lists.sourceforge.net/lists/listinfo/openrpg-v2-dev ------- End of Original Message ------- |
From: Mark T. <ma...@ly...> - 2006-05-22 21:31:37
|
Snowdog wrote: > Just wanted to shoot this out to the rest of you for some feedback. > Should the preferences/settings for openrpg follow standard unix > convention and reside in a hidden directory in the users home dir (ie > '.openrpg2' ) or should the directory be visible (id. 'openrpg2') > > Personally I'm for using the stealth version and sticking with > convention. User files (like the gametrees in whatever form they end up > being) may/may not be in this directory. Primarily this is for the > OpenRPG cache and preferences/settings that need to be retained on a > per-user basis. My vote would be to go for convention, and put it in a directory called .openrpg2 that itself is in the native operating system's notion of the current user's "home" directory. Not sure if that info is available in Java or not... although it might be. >> Mark |
From: <sno...@us...> - 2006-05-22 21:13:24
|
Revision: 68 Author: snowdog_ Date: 2006-05-22 14:13:19 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=68&view=rev Log Message: ----------- Updated server to use user configured default ip/port via new ORPGSettingManager if possible. Will still fall back to localhost automatically. Modified Paths: -------------- trunk/src/openrpg2/common/core/network/NetworkServer.java trunk/src/openrpg2/server/core/ORPGServer.java Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-05-22 21:11:15 UTC (rev 67) +++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-05-22 21:13:19 UTC (rev 68) @@ -34,10 +34,12 @@ import java.util.Iterator; import java.util.Observable; import java.util.Observer; +import java.util.Properties; import java.util.Set; import java.util.logging.Logger; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.ORPGMessageQueue; +import openrpg2.common.core.ORPGSettingManager; import openrpg2.common.module.NetworkedModule; @@ -70,6 +72,9 @@ private Logger log = Logger.getLogger(this.getClass().getName()); static final int DEFAULT_THREAD_POOL_SIZE = 5; + static final String SERVER_SETTINGS_FILENAME = "server.properties"; + static final String SETTING_DEFAULT_IP = "defaultIP"; + static final String SETTING_DEFAULT_PORT = "defaultPort"; private int threadPoolSize = DEFAULT_THREAD_POOL_SIZE; @@ -96,6 +101,38 @@ } /** + * Gets the default ip and port to run the server on by checking for user perferences first and then falling back on the hard coded defaults if no preferences exist. + * @return InetSocketAddress to run server on. + */ + public InetSocketAddress getDefaultAddress(){ + + Properties netProps = ORPGSettingManager.loadSettings(SERVER_SETTINGS_FILENAME); + String dfip = netProps.getProperty(SETTING_DEFAULT_IP); + String dfport = netProps.getProperty(SETTING_DEFAULT_PORT); + boolean resave = false; + int port; + if ( dfip == null ){ + dfip = NetworkConnection.DEFAULT_HOST; + netProps.setProperty(SETTING_DEFAULT_IP,dfip); + resave = true; + } + + if ( dfport == null){ + port = NetworkConnection.DEFAULT_PORT; + dfport = Integer.toString(port); + netProps.setProperty(SETTING_DEFAULT_PORT,dfport); + resave = true; + } else { + port = Integer.parseInt(dfport); + } + if (resave){ + ORPGSettingManager.saveSettings(netProps,SERVER_SETTINGS_FILENAME); //write the settings to settings file for later. + } + return new InetSocketAddress(dfip,port); + + } + + /** * Internal Method. Gets the next client Id number. * @return unique client id number */ Modified: trunk/src/openrpg2/server/core/ORPGServer.java =================================================================== --- trunk/src/openrpg2/server/core/ORPGServer.java 2006-05-22 21:11:15 UTC (rev 67) +++ trunk/src/openrpg2/server/core/ORPGServer.java 2006-05-22 21:13:19 UTC (rev 68) @@ -54,7 +54,7 @@ ml.setNetworkModuleProvider(server); Engine thor = new Engine(server, server, ml, d, ORPGConstants.OPMODE_SERVER); thor.start(); - server.setServerAddress(new InetSocketAddress(NetworkConnection.DEFAULT_HOST, NetworkConnection.DEFAULT_PORT)); + server.setServerAddress(server.getDefaultAddress()); server.startServer(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-05-22 21:11:23
|
Revision: 67 Author: snowdog_ Date: 2006-05-22 14:11:15 -0700 (Mon, 22 May 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=67&view=rev Log Message: ----------- Adding OpenRPG User directory code and simple user setting management that uses properties files. Added Paths: ----------- trunk/src/openrpg2/common/core/ORPGSettingManager.java trunk/src/openrpg2/common/core/ORPGUserDirs.java Added: trunk/src/openrpg2/common/core/ORPGSettingManager.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGSettingManager.java (rev 0) +++ trunk/src/openrpg2/common/core/ORPGSettingManager.java 2006-05-22 21:11:15 UTC (rev 67) @@ -0,0 +1,127 @@ +/* + * ORPGSettingManager.java + * + * Author: snowdog + * Created: May 19, 2006, 11:07 AM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; +import java.util.Properties; +import openrpg2.common.core.ORPGUserDirs; + +/** + * ORPGSettingManager offers a simple interface to handle saving and loading of Properties for the current user. + * @author snowdog + */ + +public class ORPGSettingManager { + + /** Creates a new instance of ORPGSetting */ + public ORPGSettingManager() { + } + /** + * Attempts to load properties from a file with the given name from the users OpenRPG settings directory. + * + * @param filename The simple name of the setting file to load (ie 'mysettings.properties') + * @return Properties Object. Will be empty if file not found. + * @see ORPGUserDirs + */ + public static Properties loadSettings(String filename){ + Properties p = new Properties(); + File pf = new File(ORPGUserDirs.getSettingDir(true)+filename); + if( pf.exists()){ + try { + p.load(new FileInputStream(pf)); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return p; + } + + /** + * Attempts to load properties from a file with the given name from the users OpenRPG settings directory. + * If the file does not exist then the properties from the supplied File reference will be used instead. + * @param filename The simple name of the setting file to load (ie 'mysettings.properties') + * @param template File object representing a default properties template to load if the setting file (filename) does not exist + * @return Properties Object. If the filename does not exist it will return the properties from the template file instead. If the template file cannot be used an empty properties object will be returned. + */ + public static Properties loadSettings(String filename, File template){ + Properties p = new Properties(); + File pf = new File(ORPGUserDirs.getSettingDir(true)+filename); + if( pf.exists()){ + p = loadSettings(filename); + } else { //load properties from template file + try { + p.load(new FileInputStream(template)); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + return p; + } + + /** + * Attempts to load properties from a file with the given name from the users OpenRPG settings directory. + * If the load process fails the supplied template properties object will be returned instead. + * @param filename The simple name of the setting file to load (ie 'mysettings.properties') + * @param template Properties object representing a default properties template to use if the setting file (filename) does not exist + * @return Properties Object. Either the contents of the specified file or the default template properties object. + */ + public static Properties loadSettings(String filename, Properties template){ + Properties p = new Properties(); + File pf = new File(ORPGUserDirs.getSettingDir(true)+filename); + if( pf.exists()){ + p = loadSettings(filename); + } else { //load properties from template + p = template; + } + return p; + } + + /** + * Saves the supplied Properties object to the users OpenRPG2 settings directory using the supplied filename. In the event of a filename conflict the existing file will be overwritten. + * @param p Properties object to save. + * @param filename Simple filename to use when saving properties (ie. 'mysettings.properties'} + * @return true on success. false on fail + */ + public static boolean saveSettings(Properties p, String filename){ + File pf = new File(ORPGUserDirs.getSettingDir(true)+filename); + try { + p.store(new FileOutputStream(pf),null); + } catch (FileNotFoundException ex) { + ex.printStackTrace(); + return false; + } catch (IOException ex) { + ex.printStackTrace(); + return false; + } + return true; + } + + +} Property changes on: trunk/src/openrpg2/common/core/ORPGSettingManager.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/src/openrpg2/common/core/ORPGUserDirs.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGUserDirs.java (rev 0) +++ trunk/src/openrpg2/common/core/ORPGUserDirs.java 2006-05-22 21:11:15 UTC (rev 67) @@ -0,0 +1,111 @@ +/* + * ORPGSetting.java + * + * Author: snowdog + * Created: May 19, 2006, 10:36 AM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core; + +import java.io.File; + +/** + * Group of static class methods for obtaining openrpg2 user paths. + * When paths are requested by these methods they will be created + * in the users home as required. + * @author snowdog + */ + +public class ORPGUserDirs { + + //names for OpenRPG2 directories + static private final String ORPG2_HOME = ".openrpg2"; + static private final String ORPG2_CACHE = "cache"; + static private final String ORPG2_SETTINGS = "settings"; + static private final String ORPG2_DATA = "data"; + + static private String homedir = System.getProperty("user.home");; + static private String orpg2dir = homedir+File.separator+ORPG2_HOME; + static private String orpg2cache = orpg2dir+File.separator+ORPG2_CACHE; + static private String orpg2settings = orpg2dir+File.separator+ORPG2_SETTINGS; + static private String orpg2data = orpg2dir+File.separator+ORPG2_DATA; + + /** + * ORPGuserDirs is a static class. It can be used without creating an instance of the class first. + */ + public ORPGUserDirs() { + + } + + /** + * returns a string representation of the path to the users home directory. + * @param trailingSeparator If true returned string will contain trailing directory separator character(s). + * @return path to home directory (will have trailing directory separator character(s) if trailingSeparator param was set to true) + */ + public static String getHomeDir(boolean trailingSeparator){ + setupDirectory(orpg2dir); + if (trailingSeparator){ return orpg2dir+File.separator; } + else{ return orpg2dir; } + } + + /** + * returns a string representation of the path to the users OpenRPG2 cache directory. + * @param trailingSeparator If true returned string will contain trailing directory separator character(s). + * @return path to cache directory (will have trailing directory separator character(s) if trailingSeparator param was set to true) + */ + public static String getCacheDir(boolean trailingSeparator){ + setupDirectory(orpg2cache); + if (trailingSeparator){return orpg2cache+File.separator; } + else{ return orpg2cache; } + } + + /** + * returns a string representation of the path to the users OpenRPG2 settings directory. + * @param trailingSeparator If true returned string will contain trailing directory separator character(s). + * @return path to setting directory (will have trailing directory separator character(s) if trailingSeparator param was set to true) + */ + public static String getSettingDir(boolean trailingSeparator){ + setupDirectory(orpg2settings); + if (trailingSeparator){return orpg2settings+File.separator; } + else{ return orpg2settings;} + } + + /** + * returns a string representation of the path to the users OpenRPG2 data directory. + * @param trailingSeparator If true returned string will contain trailing directory separator character(s). + * @return path to data directory (will have trailing directory separator character(s) if trailingSeparator param was set to true) + */ + public static String getDataDir(boolean trailingSeparator){ + setupDirectory(orpg2data); + if (trailingSeparator){return orpg2data+File.separator; } + else{ return orpg2data; } + } + + /** + * Internal Method used to create missing OpenRPG2 user directories if required + * @param directory directory path (as String) to check/create + */ + private static void setupDirectory(String directory){ + File dir = new File(directory); + if (!dir.exists()){ + //need to create home dir + if( !dir.mkdirs() ){ + //TODO REPORT/LOG ERRORS!! + } + } + } +} Property changes on: trunk/src/openrpg2/common/core/ORPGUserDirs.java ___________________________________________________________________ Name: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Snowdog <sn...@ga...> - 2006-05-22 20:16:07
|
Just wanted to shoot this out to the rest of you for some feedback. Should the preferences/settings for openrpg follow standard unix convention and reside in a hidden directory in the users home dir (ie '.openrpg2' ) or should the directory be visible (id. 'openrpg2') Personally I'm for using the stealth version and sticking with convention. User files (like the gametrees in whatever form they end up being) may/may not be in this directory. Primarily this is for the OpenRPG cache and preferences/settings that need to be retained on a per-user basis. opinions? --Snowdog |
From: <sno...@us...> - 2006-04-20 07:31:35
|
Revision: 66 Author: snowdog_ Date: 2006-04-20 00:31:30 -0700 (Thu, 20 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=66&view=rev Log Message: ----------- Javadoc comments added to Group and GroupManager. Couple minor code changes also but nothing to significant. Modified Paths: -------------- trunk/src/openrpg2/common/core/group/Group.java trunk/src/openrpg2/common/core/group/GroupManager.java Modified: trunk/src/openrpg2/common/core/group/Group.java =================================================================== --- trunk/src/openrpg2/common/core/group/Group.java 2006-04-19 22:59:04 UTC (rev 65) +++ trunk/src/openrpg2/common/core/group/Group.java 2006-04-20 07:31:30 UTC (rev 66) @@ -46,24 +46,36 @@ private Hashtable members = new Hashtable(); /** - * Creates a new instance of Group + * Instance a new Group with a given identification number + * @param id id number for this group */ - public Group() { - } - public Group(int id){ groupId = id; } + /** + * Instance a new Group with a given identification number and name + * @param id id number for this group + * @param name name to apply to this group + */ public Group(int id, String name){ groupId = id; groupName = name; } + /** + * Compare to supplied Group instance for equality based on id number + * @param g Group instance to compare to + * @return True if group id numbers match; otherwise false + */ public boolean equals(Group g){ return g.isGroup(groupId); } + /** + * Gets the name associated with this group. If no name has been set a default name will be returned + * @return Group name as String + */ public String getName(){ if(groupName==null){ return (DEFAULT_NAME+groupId); @@ -71,46 +83,99 @@ return groupName; } + /** + * Sets the name of this Group object + * @param name new group name as String + */ public void setName(String name){ if (name == null){return;} //sanity check groupName = name; } + /** + * Gets the short description of this group + * @return Short description of group as String. If no short description has been set an empty string will be returned. + */ public String getShortDescription(){ return groupShortDescription; } + /** + * Sets the short description for this group to the given String + * @param desc Short description String + */ public void setShortDescription(String desc){ if (desc == null){return;} //sanity check this.groupShortDescription = desc; } + /** + * Gets the long description for this group. + * @return Long description of group as String. If no long description has been set an empty string will be returned. + */ public String getLongDescription(){ return groupLongDescription; } + /** + * Sets the long description for this group to the given String + * @param desc Long description String + */ public void setLongDescription(String desc){ if (desc == null){return;} //sanity check this.groupLongDescription = desc; } + /** + * Get the id number for this group + * @return int Group id number + */ public int getGroupId(){ return groupId; } + /** + * Sets the persistance flag on this group. + * If the persistance flag is true the group will not be removed when empty of clients + * @param persist boolean. Set true to make group persistant. + */ public void setPersistance(boolean persist){ this.persistant = persist; } + /** + * Checks to see if this Group has been marked as 'persistant' and should not be removed when empty + * @return boolean. True if Group is flagged as persistant. + */ + public boolean isPersistantGroup(){ + return this.persistant; + } + + /** + * Check the group id number of this group against a supplied id number + * @param gid int. Id number to check against + * @return true if this group id matches the supplied id number. + */ public boolean isGroup(int gid){ if (groupId == gid){ return true;} return false; } + /** + * Check if this group contains a reference to a specific client id as one of the group members. + * @param id int. client id to check for. + * @return true if client is a member of this group + */ public boolean hasMember(int id){ return members.containsKey(new Integer(id)); } + /** + * Obtain a reference to a specific member of this group + * @param id The id number of the member to return reference of. + * @return GroupMember reference of member with supplied id. + * @throws openrpg2.common.core.group.InvalidMemberException Thrown if member with supplied id number does not exist in this group + */ public GroupMember getMember(int id) throws InvalidMemberException { if (!hasMember(id)){ throw new InvalidMemberException("No client with id "+id); @@ -118,10 +183,19 @@ return (GroupMember)members.get(new Integer(id)); } + /** + * Gets an Enumeration of Integers of all the member ids within this group instance. + * @return Enumeration member id numbers as Integer Objects + */ public Enumeration getMemberIds(){ return members.keys(); } + /** + * Gets a Vector of member id numbers as Integers of members that have a specified Role in this group. + * @param role Role to filter members list against + * @return Vector of member id numbers as Integer objects + */ public synchronized Vector getMembersByRole(int role){ Vector v = new Vector(); Enumeration e = members.elements(); @@ -137,6 +211,12 @@ return v; } + /** + * Gets the current Role of a specific member of the Group. + * @param member GroupMember reference to check + * @throws openrpg2.common.core.group.InvalidMemberException Thrown if group has no such member + * @return MemberRole object for Member. + */ public MemberRole getRole(GroupMember member) throws InvalidMemberException{ if(!members.containsKey(new Integer(member.getNetworkId()))){ throw new InvalidMemberException("No client with id "+member.getNetworkId()); @@ -150,21 +230,40 @@ } + /** + * Sets the Role of a member within a group + * @param member GroupMemeber to change + * @param role Role to set for memeber + */ public void setRole(GroupMember member, int role){ memberRoles.put(member, new Role(role)); } + /** + * Sets a specific member's role to the default role + * @see openrpg2.common.core.group.Role + * @param member GroupMember to change. + */ public void setDefaultRole(GroupMember member){ setRole(member, Role.DEFAULT_ROLE); } //only available at package level (default visibility used) + /** + * Checks to see if the group is empty and does not have the persistance flag set. + * @return True if the group is empty and not persistant. False otherwise. + */ boolean shouldRemoveGroup(){ if( members.isEmpty() && !persistant ){ return true; } return false; } //only available at package level (default visibility used) + /** + * Nearly identical to getMember() but may return a null reference and will not throw an Exception. + * @param id member id to retrieve. + * @return GroupMember with supplied id or null if member with supplied id cannot be located. + */ GroupMember getMemberWithNullReturn(int id) { if (!hasMember(id)){ return null; @@ -173,16 +272,28 @@ } //only available at package level (default visibility used) + /** + * Gets an Enumeration of GroupMembers associated with this group + * @return Enumeration of GroupMembers + */ synchronized Enumeration getMembers(){ return members.elements(); } //only available at package level (default visibility used) + /** + * Inserts a GroupMember object into this group. + * @param m GroupMember to add + */ void add(GroupMember m){ members.put(new Integer(m.getNetworkId()), m); } //only available at package level (default visibility used) + /** + * Removes a specific member from the group + * @param id Id number of client to remove from group + */ void remove(int id){ if (hasMember(id)){ members.remove(new Integer(id)); @@ -190,10 +301,17 @@ } //only available at package level (default visibility used) + /** + * Clears the internal members list effectively removing all members and leaving the group empty. + */ void clear(){ members.clear(); } + /** + * Gets the member count for this group. + * @return int. Number of members in this group. + */ public int size(){ return members.size(); } Modified: trunk/src/openrpg2/common/core/group/GroupManager.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-19 22:59:04 UTC (rev 65) +++ trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-20 07:31:30 UTC (rev 66) @@ -41,13 +41,28 @@ */ public class GroupManager implements Observer{ + /** + * Constant group id for the "Lobby" group + */ public static final int LOBBY_ID = 1; + /** + * Counter indexed after each group is added to ensure unique group id numbers + */ private int nextGroupId = LOBBY_ID +1; + /** + * list of registered groups keyed by group id + */ Hashtable groupList = new Hashtable(); + /** + * list of all connected clients keyed by client id + */ Hashtable clientList = new Hashtable(); private Logger log = Logger.getLogger(this.getClass().getName()); - /** Creates a new instance of GroupManager */ + /** + * Creates a new instance of GroupManager + * @param notifier callback interface reference to gain access to network message arrival announcement + */ public GroupManager(NetworkConnectionNotifier notifier) { addGroup(LOBBY_ID, "Lobby"); if (notifier != null ){ @@ -55,10 +70,19 @@ } } + /** + * Adds a new Group to the GroupManager using all default values + * @return int. Id of newly created Group + */ public int addGroup(){ return addGroup(null); } + /** + * Adds a new Group to the GroupManager with a specified name + * @param groupName String. Name to apply to new Group instance + * @return int. Id of newly created Group + */ public int addGroup(String groupName){ if ( addGroup(nextGroupId, groupName)){ nextGroupId++; @@ -68,6 +92,10 @@ } } + /** + * Get a int array of Group ids that are registered with this instance of GroupManager + * @return int[] of registered Group ids + */ public synchronized int[] getGroupIds(){ int s = groupList.size(); int[] a = new int[s]; @@ -78,6 +106,12 @@ return a; } + /** + * Internal method. Adds a new Group to the GroupManager with specific id number and name. + * @param id id number to assign to new Group + * @param groupName name to assign to new Group + * @return int. Id of newly created Group + */ private synchronized boolean addGroup(int id, String groupName){ Integer gid = new Integer(id); if (groupList.containsKey(gid)){ @@ -91,27 +125,52 @@ return true; } + /** + * Inserts a GroupClient into the client list of the GroupManager + * @param clientReference GroupClient to add to GroupManager + * @return boolean. True if add succeeded + */ private synchronized boolean addClient(GroupClient clientReference){ Integer cid = new Integer(clientReference.getNetworkId()); clientList.put(cid,clientReference); return false; } + /** + * Get a list of registered client ids + * @return Enumeration of client id numbers as Integers + */ public synchronized Enumeration getClientList(){ return clientList.keys(); - } + } + /** + * Adds a GroupMember instance into the member list of a specific Group + * @param groupId int. Id of group to add GroupMember to. + * @param m GroupMember to insert + * @return boolean. True if add succeeded. + */ public synchronized boolean addMemberToGroup(int groupId, GroupMember m){ Integer gid = new Integer(groupId); if (!clientList.containsKey(new Integer(m.getNetworkId()))){ return false; } //sanity check if(groupList.containsKey(gid)){ Group group = (Group)groupList.get(gid); - group.add(m); - return true; + if(group.hasMember(m.getNetworkId())){ + return true; + }else{ + group.add(m); + return true; + } } return false; } + /** + * Adds a GroupMember instance into the member list of a specific Group + * @param groupId int. Id of group to add GroupMember to. + * @param clientId int. Id of GroupMember to add to Group. + * @return boolean. True if add succeeded. + */ public synchronized boolean addMemberToGroup(int groupId, int clientId){ Integer gid = new Integer(groupId); Integer cid = new Integer(clientId); @@ -121,30 +180,28 @@ return addMemberToGroup(groupId, m); } + /** + * Moves a client reference out of one group and into another. + * @param clientId int. Id of GroupMember to move. + * @param fromGroupId int. Id of Group to get member from. + * @param toGroupId int. Id of Group to move member to. + * @return boolean. True if move succeeded + */ public synchronized boolean changeMemberGroup(int clientId, int fromGroupId, int toGroupId){ - Integer fgid = new Integer(fromGroupId); - Integer tgid = new Integer(toGroupId); - if (!groupList.containsKey(fgid)){ return false; } //sanity check - if (!groupList.containsKey(fgid)){ return false; } //sanity check - if (fromGroupId == toGroupId){ return true; } //sanity check - GroupMember m = null; - try{ - m = locateMemberReference(clientId, fromGroupId); - }catch(InvalidMemberException e){ - return false; - }catch(InvalidGroupException g){ - return false; + if(addMemberToGroup(toGroupId,clientId)){ + if(dropClientFromGroup(clientId, fromGroupId)){ + return true; + } } - ((Group)groupList.get(fgid)).remove(clientId); - checkGroupRemovable(fromGroupId); - Group g = ((Group)groupList.get(tgid)); - if(g.hasMember(clientId)){ - return true; - } - g.add(m); - return true; + return false; } + /** + * Remove a specific member from a specific group + * @param clientId int. Id of member to remove + * @param groupId int. Group Id from which to remove member + * @return boolean. True if remove succeeded + */ public synchronized boolean dropClientFromGroup(int clientId, int groupId){ Integer gid = new Integer(groupId); if (!groupList.containsKey(gid)){ return false; } //sanity check @@ -162,6 +219,11 @@ return true; } + /** + * Gets the count of how many GroupMember instances for a particular member id are currently registered + * @param id int. Id of member to count + * @return number of GroupMember instances exist for supplied client id number + */ private synchronized int countMemberInstances(int id){ Enumeration groups = groupList.elements(); int count = 0; @@ -174,17 +236,30 @@ return count; } + /** + * Checks if a group should be removed or not. + * Groups are normally removed from the GroupManager when they are no longer in use + * (i.e. have no members associated with the Group) + * @param id int. Id of Group to check + */ private void checkGroupRemovable(int id){ Integer gid = new Integer(id); if( id == LOBBY_ID){ return; } //sanity check; can't remove lobby if( ! groupList.containsKey(gid)){ return; } //sanity check Group g = (Group) groupList.get(gid); - - if (g.shouldRemoveGroup() ){ + if (g.shouldRemoveGroup() ){ groupList.remove(gid); } } + /** + * Internal Method. Attempts to locate and return a GroupMember reference from a given Group + * @param id int. Id of GroupMember to locate + * @param groupId int. Id of Group to look for GroupMember in. + * @return GroupMember reference for supplied member id + * @throws openrpg2.common.core.group.InvalidMemberException Thrown if Member does not exist in specified Group + * @throws openrpg2.common.core.group.InvalidGroupException Thrown if Group id is invalid + */ private synchronized GroupMember locateMemberReference(int id, int groupId) throws InvalidMemberException, InvalidGroupException{ Integer gid = new Integer(groupId); @@ -199,6 +274,12 @@ throw new InvalidMemberException("No such member -> "+id); } + /** + * Internal method. Checks registered client list and attempts to return a GroupClient reference for a given client id number + * @param id int. Id for client to locate + * @return GroupClient reference for + * @throws openrpg2.common.core.group.InvalidMemberException Thrown if client id does not exist in client list + */ private synchronized GroupClient locateClientReference(int id) throws InvalidMemberException{ Integer i = new Integer(id); if (clientList.containsKey(i)){ @@ -207,6 +288,11 @@ throw new InvalidMemberException("No such member -> "+id); } + /** + * Creates and inserts a new GroupClient with a specified id into the GroupManager. + * This method also automatically places the client into the default (Lobby) Group. + * @param id int. client id of GroupClient to add. + */ public synchronized void clientConnect(int id){ GroupClient c = new GroupClient(new Integer(id)); addClient(c); @@ -215,6 +301,12 @@ } + /** + * Informs the GroupManager that a client has disconnected from the server. + * Automatically removes the registered GroupClient reference and all GroupMember + * references for the disconnecting client from all Groups + * @param id int. Id of client to remove + */ public synchronized void clientDisconnect(int id){ //remove client references from group Enumeration groups = groupList.elements(); @@ -224,7 +316,7 @@ checkGroupRemovable(g.getGroupId()); } //prune out client from clientList - clientList.remove(id); + clientList.remove(id); } public void DEBUG_PRINTCLIENTLIST(){ @@ -250,10 +342,7 @@ ex.printStackTrace(); } String role; - if (r.isGM()){role = "[GM] ";} - else if (r.isGhost()){role="[G] ";} - else if (r.isLurker()){role="[L] ";} - else{ role="[P] ";} + if (r.isGM()){role = "[GM] ";} else if (r.isGhost()){role="[G] ";} else if (r.isLurker()){role="[L] ";} else{ role="[P] ";} System.out.print(role+m.getDisplayName()+"("+m.getNetworkId()+")"); if (members.hasMoreElements()){ System.out.print(", ");} } @@ -261,13 +350,19 @@ } } + /** + * Get the GroupClient object associated with a specific id number + * @param id int. Id of client to retrieve + * @return GroupClient with supplied client id + * @throws openrpg2.common.core.group.InvalidMemberException Thrown if client id is not in client list + */ public GroupClient getClient(int id)throws InvalidMemberException{ return locateClientReference(id) ; } /** * Creates a new GroupMember object tied to a specific client id. - * + * * @return GroupMember object that is not bound to a specific group. If clientId is invalid null will be returned instead * @param clientId client id number */ @@ -276,11 +371,17 @@ try { gc = locateClientReference(clientId); } catch (InvalidMemberException ex) { - gc = null; + gc = null; } return new GroupMember(gc); } + /** + * Get a Group reference for a specific group id number + * @param id int. Id number of Group to retrieve. + * @return Group reference for supplied group id number + * @throws openrpg2.common.core.group.InvalidGroupException Thrown if no such group exists in the GroupManager lists + */ public Group getGroup(int id) throws InvalidGroupException{ Integer gid = new Integer(id); if ( !groupList.containsKey(gid)){ @@ -290,6 +391,14 @@ } + /** + * Satisfies Observer interface requirements. + * This method is called by the network to inform the GroupManager + * of connection and disconnection of clients on the server. This method + * should not be called directly. + * @param o Calling Observable reference + * @param arg NetworkClientState object to indicate state of network connection + */ public void update(Observable o, Object arg){ if (o instanceof NetworkConnectionAlerter ){ NetworkClientState ncs = (NetworkClientState)arg; @@ -305,10 +414,20 @@ } } + /** + * Get the GroupClientModule. + * This method allows the OpenRPG2 client to retrieve the client side group module. + * @return GroupClientModule instance + */ public GroupClientModule getGroupClientModule(){ return new GroupClientModule(this); } + /** + * Get the GroupServerModule. + * This method allows the OpenRPG2 server to retrieve the server side group module. + * @return GroupServerModule instance + */ public GroupServerModule getGroupServerModule(){ return new GroupServerModule(this); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-19 22:59:08
|
Revision: 65 Author: snowdog_ Date: 2006-04-19 15:59:04 -0700 (Wed, 19 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=65&view=rev Log Message: ----------- Updated javadoc comments for route package Modified Paths: -------------- trunk/src/openrpg2/common/core/route/MessageAddress.java trunk/src/openrpg2/common/core/route/RouteManager.java trunk/src/openrpg2/common/core/route/RouteServiceThread.java Modified: trunk/src/openrpg2/common/core/route/MessageAddress.java =================================================================== --- trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-19 20:57:42 UTC (rev 64) +++ trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-19 22:59:04 UTC (rev 65) @@ -26,56 +26,84 @@ import java.util.Vector; /** - * + * A MessageAddress object encompasses one or more routing directives + * (AddressTokens) that determine a group of clients id numbers. MessageAddress + * objects are part of the OpenRPG2 message routing system and are responsible + * for making sure messages get delivered to the proper clients from the server. * @author Snowdog + * @see openrpg2.common.core.route.AddressToken */ public class MessageAddress { static final String ADDRESS_TOKEN_SEPARATOR = ":"; Vector address = new Vector(); - /** Creates a new instance of MessageAddress */ + /** + * Instance a new MessageAddress object with no AddressTokens added. + * A MessageAddres with no tokens is unroutable and will result in an empty + * client recipient set which in turn will cause an ORPGMessage to be discarded. + */ public MessageAddress() { } + /** + * Instance a new MessageAddress object with base AddressToken added. + * @param token An initial AddressToken to add to MessageAddress + */ public MessageAddress(AddressToken token){ append(token); } + /** + * Appends a new AddressToken to a MessageAddress instance. + * @param token AddressToken to append + * @return boolean True if append successful. False on fail. In general this result should always return true and can be safely ignored in most cases. + */ public boolean append(AddressToken token){ return address.add(token); } + /** + * Clears all AddressTokens from a MessageAddress instance. + */ public void clear(){ Vector address = new Vector(); } /** - * Accesses the raw AddressTokens of this MessageAddress + * Accesses the raw AddressTokens of this MessageAddress object. + * @return Enumeration of AddressToken Objects */ public Enumeration getTokens(){ return address.elements(); } + /** + * This method loads the MessageAddress object with AddressTokens parsed from a supplied String. + * This is normally used by the routing code when transfering messages from the network. + * @param addressString String as generated by the encode() method + */ public void convert(String addressString){ clear(); - AddressToken t = null; + AddressToken t = null; StringTokenizer tok = new StringTokenizer(addressString, ADDRESS_TOKEN_SEPARATOR); while(tok.hasMoreTokens()){ try { - t = AddressToken.convert(tok.nextToken()); - address.add(t); + t = AddressToken.convert(tok.nextToken()); + address.add(t); } catch (InvalidMessageTargetException ex) { //ignore (discard) invalid or malformed address tokens } } } + /** + * Generate an encoded representation of a MessageAddress instance as a String + * This method is used primarily by the networking code to convert destination addresses + * into a form convient for sending via the network. + * @return String representation of MessageAddress + */ public String encode(){ - return toString(); - } - - public String toString(){ StringBuffer buf = new StringBuffer(); Enumeration list = address.elements(); while( list.hasMoreElements()){ @@ -83,5 +111,15 @@ buf.append( AddressToken.encode(t) ) ; } return buf.toString(); + } + + /** + * convienence method. Same as MessageAddress.encode(). + * A string generated by this method can be fed into the convert() method. + * @return String representation of MessageAddress + */ + public String toString(){ + return encode(); + } } Modified: trunk/src/openrpg2/common/core/route/RouteManager.java =================================================================== --- trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-19 20:57:42 UTC (rev 64) +++ trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-19 22:59:04 UTC (rev 65) @@ -56,6 +56,10 @@ /** * Creates a new instance of RouteManager + * @param locatorRef NetworkedModuleLocater to allow access to the network module + * @param network NetworkMessageRelay reference to allow RouteManager to transfer messages to/from the network + * @param groupManagerRef GroupManager reference for access to group and client data + * @param isClient Boolean True if operating as a client (clients do not do route resolution at all. Routing services are always server side) */ public RouteManager(NetworkedModuleLocator locatorRef, NetworkMessageRelay network, GroupManager groupManagerRef, boolean isClient) { //initialize the thread pool @@ -71,6 +75,9 @@ start(); } + /** + * Starts an internal unamed thread to delegate tasks to RouteThreadPool threads. + */ private void start(){ runFlag=true; @@ -93,6 +100,9 @@ routingThread.start(); } + /** + * Stops internal unamed thread. + */ private void stop(){ runFlag = false; synchronized(lock){ @@ -100,6 +110,10 @@ } } + /** + * Transfers an ORPGMessage to the network and does route resolution if required + * @param msg ORPGMessage with destination MessageAddress to send to network + */ public void sendMessageToNetwork(ORPGMessage msg){ if (msg == null ){ return;} //sanity check //address resolution not required by client side routing @@ -114,6 +128,8 @@ * This method resolves the supplied ORPGMessage address and loads the messages * internal int[] of client destination ids. It handles removing duplicate references so only * one copy of the message will be delivered to a given client. + * @param msg ORPGMessage to resolve addressed for + * @return The supplied ORPGMessage object with recipient array set. */ private ORPGMessage resolveMessageAddress(ORPGMessage msg){ ORPGMessage m = msg; @@ -136,6 +152,11 @@ return m; } + /** + * Internal method to update supplied vector with client ids as defined by supplied AddressToken + * @param v Vector of Integers to update + * @param t AddressToken to parse + */ private void updateValidClientsVector(Vector v, AddressToken t){ Vector currentToken = new Vector(); //find out what kind of target is called for @@ -223,6 +244,12 @@ } } + /** + * merges two Integer Vectors without duplicating elements. + * @param v1 Vector of Integers to merge data into + * @param v2 Vector of Integers used to update v1 + * @return reference to supplied Vector v1 + */ private Vector joinClientVectors(Vector v1, Vector v2){ Enumeration e = v2.elements(); while(e.hasMoreElements()){ @@ -234,6 +261,12 @@ return v1; } + /** + * merges two Integer Vectors removing all reference to elements in the second Vector from the first. + * @param originalVector Vector of Integers to remove data from + * @param excludeVector Vector of Integers values to remove from v1 + * @return reference to supplied Vector v1 + */ private Vector excludeClientVector(Vector originalVector, Vector excludeVector){ Enumeration e = excludeVector.elements(); while(e.hasMoreElements()){ @@ -243,13 +276,25 @@ } //implements update method of Observer interface; + /** + * Called by network to alert RouteManager than a message has arrived from the network + * and is awaiting processing. <b>This method satisfies the Observer Interface and should not + * be called directly</b> + * Only monitoring one queue (incoming from network) so no check on which Observable notified + * us is made and the argument is not used. + * @param o Observable that has caused notification (ignored) + * @param arg Observable argument (not used) + */ public void update(Observable o, Object arg){ - //only monitoring one queue (incoming from network) so doing no check on which Observable notified us. + synchronized(lock){ lock.notify(); //wake this thread } } + /** + * Cleanup method to ensure resources are properly released upon object death. + */ protected void finalize() { stop(); threadPool.shutdownThreads(); Modified: trunk/src/openrpg2/common/core/route/RouteServiceThread.java =================================================================== --- trunk/src/openrpg2/common/core/route/RouteServiceThread.java 2006-04-19 20:57:42 UTC (rev 64) +++ trunk/src/openrpg2/common/core/route/RouteServiceThread.java 2006-04-19 22:59:04 UTC (rev 65) @@ -82,6 +82,10 @@ } } + /** + * Signals the RouteServiceThread to perform a send operation to relay an ORPGMessage to the network + * @param m ORPGMessage to send + */ public void send(ORPGMessage m){ this.mode = SEND_MODE; @@ -91,6 +95,9 @@ } } + /** + * Signals the RouteServiceThread to perform a fetch operation to retrieve an ORPGMessage from the network. + */ public void fetch(){ try{ this.msg = messageRelay.getORPGMessage(); @@ -104,6 +111,9 @@ } } + /** + * Internal Method to handle the threaded send operation. + */ private void sendService(){ //TODO: Add outbound filter hooks @@ -121,6 +131,9 @@ this.threadPool.returnServiceThread(this); } + /** + * Internal Method to handle the threaded fetch operation. + */ private void fetchService(){ //TODO: run though 'initialization' filter first. @@ -151,6 +164,14 @@ } + /** + * This method manages the actual message processing by a specific module. + * The ORPGMessage currently registered with this thread will be handed to the + * supplied NetworkedModule for handling. <b>Note: this thread bears the weight + * of module side processing and will not return to its threadpool until the processing + * is complete.</b> + * @param handler Module reference that should handle the ORPGMessage registered with the RouteServiceThread + */ private void processMessage(NetworkedModule handler){ if ( msg == null){ return;} //sanity check if ( handler == null){return;} //sanity check This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-19 20:57:52
|
Revision: 64 Author: snowdog_ Date: 2006-04-19 13:57:42 -0700 (Wed, 19 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=64&view=rev Log Message: ----------- Changes to routing and network code to allow clients to specify destination addresses and transmit those addresses in NetworkMessages. Updated ExampleClientModule to direct popup messages to all clients in the 'Lobby' using a MessageAddress in the message. Revised DefaultRelay to honor client supplied addressing information and relay messages based on the client supplied addresses. (Forwarding Behavior) Modified Paths: -------------- trunk/src/openrpg2/client/core/modules/ExampleClientModule.java trunk/src/openrpg2/common/core/ORPGMessage.java trunk/src/openrpg2/common/core/network/NetworkServer.java trunk/src/openrpg2/common/core/route/MessageAddress.java trunk/src/openrpg2/common/core/route/RouteManager.java trunk/src/openrpg2/server/core/modules/DefaultRelay.java Modified: trunk/src/openrpg2/client/core/modules/ExampleClientModule.java =================================================================== --- trunk/src/openrpg2/client/core/modules/ExampleClientModule.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/client/core/modules/ExampleClientModule.java 2006-04-19 20:57:42 UTC (rev 64) @@ -30,6 +30,7 @@ import javax.swing.JPanel; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.engine.ModuleCommunicationException; +import openrpg2.common.core.group.GroupManager; import openrpg2.common.core.route.AddressToken; import openrpg2.common.core.route.MessageAddress; import openrpg2.common.module.ClientLoadable; @@ -75,7 +76,7 @@ msg.setHeader("PopText","ExampleClientModule is annoying you with a popup"); MessageAddress sendTo = new MessageAddress(); - sendTo.append(new AddressToken(AddressToken.BROADCAST,0)); //send to all clients + sendTo.append(new AddressToken(AddressToken.ALL,GroupManager.LOBBY_ID)); //send to all clients msg.setDestination(sendTo); try{ this.modCom.sendToNetwork(msg); Modified: trunk/src/openrpg2/common/core/ORPGMessage.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGMessage.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/common/core/ORPGMessage.java 2006-04-19 20:57:42 UTC (rev 64) @@ -78,7 +78,8 @@ originatorId = senderConnectionId; header = n.getHeaderAsHashtable(); handlerId = getHeader(ORPGConstants.MESSAGE_TYPE); - + destination = new MessageAddress(); + destination.convert(getHeader(ORPGConstants.MESSAGE_DESTINATION)); data = n.getData(); } @@ -93,6 +94,7 @@ } public NetworkMessage asNetworkMessage(){ + setHeader(ORPGConstants.MESSAGE_DESTINATION, destination.encode()); NetworkMessage netmsg = new NetworkMessage(this.getEncodedHeaderString(), this.getData()); return netmsg; } Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-19 20:57:42 UTC (rev 64) @@ -395,9 +395,8 @@ * @param o An Observer Object to register for network state notification */ public void registerNetworkConnectionObserver(Observer o){ - log.warning("ADDING OBSERVER!"); connectionState.addObserver(o); - connectionState.announceConnection(1); + } Modified: trunk/src/openrpg2/common/core/route/MessageAddress.java =================================================================== --- trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-19 20:57:42 UTC (rev 64) @@ -57,7 +57,7 @@ return address.elements(); } - public Enumeration convert(String addressString){ + public void convert(String addressString){ clear(); AddressToken t = null; StringTokenizer tok = new StringTokenizer(addressString, ADDRESS_TOKEN_SEPARATOR); @@ -69,7 +69,6 @@ //ignore (discard) invalid or malformed address tokens } } - return address.elements(); } public String encode(){ Modified: trunk/src/openrpg2/common/core/route/RouteManager.java =================================================================== --- trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-19 20:57:42 UTC (rev 64) @@ -127,7 +127,12 @@ } //build int[] of clients. - + int s = validClients.size(); + int[] n = new int[s]; + for(int i = 0; i < s; i++){ + n[i] = ((Integer)validClients.elementAt(i)).intValue(); + } + m.setFinalRecipientList(n); return m; } Modified: trunk/src/openrpg2/server/core/modules/DefaultRelay.java =================================================================== --- trunk/src/openrpg2/server/core/modules/DefaultRelay.java 2006-04-19 08:57:53 UTC (rev 63) +++ trunk/src/openrpg2/server/core/modules/DefaultRelay.java 2006-04-19 20:57:42 UTC (rev 64) @@ -49,7 +49,7 @@ public void processMessage(ORPGMessage msg){ try{ - log.info("DEBUG: DefaultRelay is handing a message from "+msg.getOriginatorId()+" of type: "+msg.getHandlerId()); + log.info("DEBUG: DefaultRelay is handing a message from "+msg.getOriginatorId()+" of type: "+msg.getHandlerId()+" dest: "+msg.getDestination().toString()); //System.out.println("DEBUG: modCom = "+modCom.toString()); }catch (Exception a){ log.warning("Exception: "+a.getMessage()); @@ -57,16 +57,8 @@ } //relay message back to originator - MessageAddress a = new MessageAddress(); - a.append(new AddressToken(AddressToken.CLIENT,msg.getOriginatorId())); + MessageAddress a = msg.getDestination(); msg.setDestination(a); - //---------------- temporary code start ---------------------------- - // Remove this code once the routing/addressing system is complete - // Manually forcing bounce to sender behavior for testing purposes - int[] sendto = {msg.getOriginatorId()}; - msg.setFinalRecipientList(sendto); - // - //--------------- temporary code end ------------------------- try{ modCom.sendToNetwork(msg); }catch (ModuleCommunicationException e){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-19 08:58:03
|
Revision: 63 Author: snowdog_ Date: 2006-04-19 01:57:53 -0700 (Wed, 19 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=63&view=rev Log Message: ----------- Integrated message preliminary routing code into core. ORPGMessages must now contain a valid MessageAddress or the message send will fail with a DevConsole warning. ExampleClientModule has been updated to use a MessageAddress in its messages which have been directed to 'BROADCAST'. Eventually client sent broadcast messages will be dropped by the server. Only the server itself will be allowed to broadcast messages to all clients. Modified Paths: -------------- trunk/src/openrpg2/client/core/modules/ExampleClientModule.java trunk/src/openrpg2/common/core/engine/Engine.java trunk/src/openrpg2/common/core/engine/ModuleManager.java trunk/src/openrpg2/common/core/group/Group.java trunk/src/openrpg2/common/core/group/GroupManager.java trunk/src/openrpg2/common/core/route/AddressToken.java trunk/src/openrpg2/common/core/route/MessageAddress.java trunk/src/openrpg2/common/core/route/RouteManager.java Modified: trunk/src/openrpg2/client/core/modules/ExampleClientModule.java =================================================================== --- trunk/src/openrpg2/client/core/modules/ExampleClientModule.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/client/core/modules/ExampleClientModule.java 2006-04-19 08:57:53 UTC (rev 63) @@ -25,12 +25,13 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.JButton; -import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JOptionPane; import javax.swing.JPanel; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.engine.ModuleCommunicationException; +import openrpg2.common.core.route.AddressToken; +import openrpg2.common.core.route.MessageAddress; import openrpg2.common.module.ClientLoadable; import openrpg2.common.module.NetworkedModule; @@ -72,6 +73,10 @@ ORPGMessage msg = new ORPGMessage(); msg.setHandlerId("Popup"); msg.setHeader("PopText","ExampleClientModule is annoying you with a popup"); + + MessageAddress sendTo = new MessageAddress(); + sendTo.append(new AddressToken(AddressToken.BROADCAST,0)); //send to all clients + msg.setDestination(sendTo); try{ this.modCom.sendToNetwork(msg); }catch(ModuleCommunicationException e){ Modified: trunk/src/openrpg2/common/core/engine/Engine.java =================================================================== --- trunk/src/openrpg2/common/core/engine/Engine.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/engine/Engine.java 2006-04-19 08:57:53 UTC (rev 63) @@ -112,6 +112,8 @@ moduleManager.registerGUIManager(guiManager); moduleManager.registerGroupManager(groupManager); moduleManager.registerNetwork(networkRelay); + routeManager = new RouteManager(moduleManager, networkRelay, groupManager, isClientMode()); + moduleManager.registerRouteManager(routeManager); try{ moduleManager.initialize(); }catch (NoNetworkHookException nnhe ){ @@ -129,9 +131,13 @@ System.exit(ORPGConstants.FATAL_NETWORK_MODULE_FAIL); } - routeManager = new RouteManager(moduleManager, networkRelay); + } + private boolean isClientMode(){ + return (OperationMode == ORPGConstants.OPMODE_CLIENT); + } + public void routeORPGMessageToNetwork(ORPGMessage msg){ routeManager.sendMessageToNetwork(msg); } Modified: trunk/src/openrpg2/common/core/engine/ModuleManager.java =================================================================== --- trunk/src/openrpg2/common/core/engine/ModuleManager.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/engine/ModuleManager.java 2006-04-19 08:57:53 UTC (rev 63) @@ -28,6 +28,7 @@ import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.group.GroupManager; import openrpg2.common.core.gui.GUIManager; +import openrpg2.common.core.route.RouteManager; import openrpg2.common.module.BaseModule; @@ -49,6 +50,7 @@ private ModuleLoader moduleLoader = null; private GUIManager guiManager = null; private GroupManager groupManager = null; + private RouteManager routeManager = null; private Logger log = Logger.getLogger(this.getClass().getName()); @@ -133,7 +135,15 @@ groupManager = m; } + /** + * Registers a RouteManager with the ModuleManager + * @param m Reference to the RouteManager object that will supply message routing serivices. + */ + public void registerRouteManager(RouteManager m){ + routeManager = m; + } + /** * Called to initialize the ModuleManager. Does a sanity check to make sure the * Network hook and module loader are present then initializes the ModuleManager @@ -311,11 +321,14 @@ * @throws openrpg2.common.core.engine.ModuleCommunicationException Thrown if network is not available. */ public void sendToNetwork( ORPGMessage msg ) throws ModuleCommunicationException{ - + if ( msg.getDestination() == null){ + log.warning("Message for module "+msg.getHandlerId()+" dropped due to missing address information."); + return; + } if ( ! isInitialized() ){ throw new ModuleCommunicationException("Network Not Available"); } - networkHook.putORPGMessage(msg); + routeManager.sendMessageToNetwork(msg); } Modified: trunk/src/openrpg2/common/core/group/Group.java =================================================================== --- trunk/src/openrpg2/common/core/group/Group.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/group/Group.java 2006-04-19 08:57:53 UTC (rev 63) @@ -21,10 +21,9 @@ package openrpg2.common.core.group; -import java.util.ArrayList; import java.util.Enumeration; import java.util.Hashtable; -import java.util.Iterator; +import java.util.Vector; /** * Group represents a logical grouping of clients on the server. @@ -119,6 +118,25 @@ return (GroupMember)members.get(new Integer(id)); } + public Enumeration getMemberIds(){ + return members.keys(); + } + + public synchronized Vector getMembersByRole(int role){ + Vector v = new Vector(); + Enumeration e = members.elements(); + while(e.hasMoreElements()){ + GroupMember m = (GroupMember)e.nextElement(); + try { + MemberRole r = getRole(m); + if (r.equals(role)){ + v.add(new Integer(m.getNetworkId())); + } + } catch (InvalidMemberException ex) {} + } + return v; + } + public MemberRole getRole(GroupMember member) throws InvalidMemberException{ if(!members.containsKey(new Integer(member.getNetworkId()))){ throw new InvalidMemberException("No client with id "+member.getNetworkId()); @@ -153,7 +171,7 @@ } return (GroupMember)members.get(new Integer(id)); } - + //only available at package level (default visibility used) synchronized Enumeration getMembers(){ return members.elements(); Modified: trunk/src/openrpg2/common/core/group/GroupManager.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-19 08:57:53 UTC (rev 63) @@ -97,6 +97,10 @@ return false; } + public synchronized Enumeration getClientList(){ + return clientList.keys(); + } + public synchronized boolean addMemberToGroup(int groupId, GroupMember m){ Integer gid = new Integer(groupId); if (!clientList.containsKey(new Integer(m.getNetworkId()))){ return false; } //sanity check @@ -220,9 +224,7 @@ checkGroupRemovable(g.getGroupId()); } //prune out client from clientList - clientList.remove(id); - - + clientList.remove(id); } public void DEBUG_PRINTCLIENTLIST(){ Modified: trunk/src/openrpg2/common/core/route/AddressToken.java =================================================================== --- trunk/src/openrpg2/common/core/route/AddressToken.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/route/AddressToken.java 2006-04-19 08:57:53 UTC (rev 63) @@ -122,6 +122,14 @@ } /** + * Gets the state of the exclude flag of this AddressToken + * @return boolean. True only if exclude flag set. + */ + public boolean getExcluded(){ + return this.exclude; + } + + /** * Sets the target of the address. See predefined target constants in MessageAddress * @param target A single char representing the addressing target of this message * @return boolean. True if target setting was valid, false if target is not valid @@ -135,6 +143,15 @@ } /** + * Retrieves the target of this AddressToken. + * @return char target descriptor (see constants for AddressToken) + */ + public char getTarget(){ + return this.target; + } + + + /** * Sets the client or group id number. * @param id client or group id 'target' for this address object */ @@ -143,6 +160,15 @@ } /** + * Retrieves the id number associated with this AddressToken + * @return id number of the client or group relevant to the Target + */ + public int getId(){ + return this.id; + } + + + /** * Generates an encoded address string for this object * @return encoded message address String. */ @@ -204,7 +230,7 @@ /** * convert() serves as the counterpart to the encode() method. - * It converts address tokens as created by encode() back into MessageAddress objects. + * It converts address tokens as created by encode() back into MessageAddressToken objects. * This is a static method. * @param addressToken A single address token as generated by encode() or toString() * @throws openrpg2.common.core.route.InvalidMessageTargetException Thrown when errors occure while converting the message address Modified: trunk/src/openrpg2/common/core/route/MessageAddress.java =================================================================== --- trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-19 08:57:53 UTC (rev 63) @@ -50,6 +50,13 @@ Vector address = new Vector(); } + /** + * Accesses the raw AddressTokens of this MessageAddress + */ + public Enumeration getTokens(){ + return address.elements(); + } + public Enumeration convert(String addressString){ clear(); AddressToken t = null; Modified: trunk/src/openrpg2/common/core/route/RouteManager.java =================================================================== --- trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-18 22:54:17 UTC (rev 62) +++ trunk/src/openrpg2/common/core/route/RouteManager.java 2006-04-19 08:57:53 UTC (rev 63) @@ -20,11 +20,19 @@ */ package openrpg2.common.core.route; +import java.util.Enumeration; import java.util.Observable; import java.util.Observer; +import java.util.Vector; import java.util.logging.Logger; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.engine.NetworkedModuleLocator; +import openrpg2.common.core.group.Group; +import openrpg2.common.core.group.GroupClient; +import openrpg2.common.core.group.GroupManager; +import openrpg2.common.core.group.InvalidGroupException; +import openrpg2.common.core.group.InvalidMemberException; +import openrpg2.common.core.group.Role; import openrpg2.common.core.network.NetworkMessageRelay; import openrpg2.common.core.network.NoObservableExistsException; @@ -41,15 +49,19 @@ private boolean runFlag = false; private Thread routingThread = null; private NetworkMessageRelay networkRelay = null; + private GroupManager groupManager = null; + private boolean inClientMode = false; private Object lock = new Object(); private Logger log = Logger.getLogger(this.getClass().getName()); /** - * Creates a new instance of RouteManager + * Creates a new instance of RouteManager */ - public RouteManager(NetworkedModuleLocator locatorRef, NetworkMessageRelay network) { + public RouteManager(NetworkedModuleLocator locatorRef, NetworkMessageRelay network, GroupManager groupManagerRef, boolean isClient) { //initialize the thread pool + groupManager = groupManagerRef; networkRelay = network; + inClientMode = isClient; try{ networkRelay.addMessageQueueObserver(this); }catch (NoObservableExistsException e){ @@ -80,27 +92,159 @@ }; routingThread.start(); } - + private void stop(){ runFlag = false; synchronized(lock){ lock.notify(); //wake this thread } - } + } - public void sendMessageToNetwork(ORPGMessage msg){ - RouteServiceThread sendThread = threadPool.getServiceThread(); - sendThread.send(msg); //hand message to RouteServiceThread and release the thread. - } + public void sendMessageToNetwork(ORPGMessage msg){ + if (msg == null ){ return;} //sanity check + //address resolution not required by client side routing + if (!inClientMode){ + msg = resolveMessageAddress(msg); + } + RouteServiceThread sendThread = threadPool.getServiceThread(); + sendThread.send(msg); //hand message to RouteServiceThread and release the thread. + } - //implements update method of Observer interface; - public void update(Observable o, Object arg){ - //only monitoring one queue (incoming from network) so doing no check on which Observable notified us. - synchronized(lock){ + /** + * This method resolves the supplied ORPGMessage address and loads the messages + * internal int[] of client destination ids. It handles removing duplicate references so only + * one copy of the message will be delivered to a given client. + */ + private ORPGMessage resolveMessageAddress(ORPGMessage msg){ + ORPGMessage m = msg; + MessageAddress a = msg.getDestination(); + log.fine("Resolving address for message address: "+a.toString()); + Vector validClients = new Vector(); + Enumeration tokens = a.getTokens(); + while( tokens.hasMoreElements()){ + AddressToken t = (AddressToken)tokens.nextElement(); + updateValidClientsVector(validClients, t); + } + + //build int[] of clients. + + return m; + } + + private void updateValidClientsVector(Vector v, AddressToken t){ + Vector currentToken = new Vector(); + //find out what kind of target is called for + char target = t.getTarget(); + switch(target){ + case(AddressToken.BROADCAST):{ + Enumeration clients = groupManager.getClientList(); + while( clients.hasMoreElements()){ + Integer i = (Integer)clients.nextElement(); + currentToken.add(new Integer(i.intValue())); //deep copy to protect original references + } + break; + } + case(AddressToken.ALL):{ + Group g; + try { g = groupManager.getGroup(t.getId()); + } catch (InvalidGroupException ex) { + log.fine("Invalid group id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + Enumeration members = g.getMemberIds(); + while (members.hasMoreElements()){ + Integer i = (Integer)members.nextElement(); + currentToken.add(new Integer(i.intValue())); //deep copy to protect original references + } + break; + } + case(AddressToken.CLIENT):{ + GroupClient c; + try { + c = groupManager.getClient(t.getId()); + } catch (InvalidMemberException ex) { + log.fine("Invalid member id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + currentToken.add(new Integer(c.getNetworkId())); + break; + } + case(AddressToken.GM):{ + Group g; + try { g = groupManager.getGroup(t.getId()); + } catch (InvalidGroupException ex) { + log.fine("Invalid group id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + currentToken.addAll(g.getMembersByRole(Role.ROLE_GM)); + break; + } + case(AddressToken.PLAYERS):{ + Group g; + try { g = groupManager.getGroup(t.getId()); + } catch (InvalidGroupException ex) { + log.fine("Invalid group id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + currentToken.addAll(g.getMembersByRole(Role.ROLE_PLAYER)); + break; + } + case(AddressToken.LURKERS):{ + Group g; + try { g = groupManager.getGroup(t.getId()); + } catch (InvalidGroupException ex) { + log.fine("Invalid group id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + currentToken.addAll(g.getMembersByRole(Role.ROLE_LURKER)); + break; + } + case(AddressToken.INVISIBLES):{ + Group g; + try { g = groupManager.getGroup(t.getId()); + } catch (InvalidGroupException ex) { + log.fine("Invalid group id ("+t.getId()+") in message. Dropping token: "+t.toString()); + return; //bailout on this token and ignore + } + currentToken.addAll(g.getMembersByRole(Role.ROLE_GHOST)); + break; + } + default:{return;} //default simply bails out and does nothing + }//end of switch statement + if (t.getExcluded()){ + v = excludeClientVector(v,currentToken); + }else{ + v = joinClientVectors(v,currentToken); + } + } + + private Vector joinClientVectors(Vector v1, Vector v2){ + Enumeration e = v2.elements(); + while(e.hasMoreElements()){ + Integer i = (Integer)e.nextElement(); + if (!v1.contains(i)){ + v1.add(i); + } + } + return v1; + } + + private Vector excludeClientVector(Vector originalVector, Vector excludeVector){ + Enumeration e = excludeVector.elements(); + while(e.hasMoreElements()){ + originalVector.remove((Integer)e.nextElement()); + } + return originalVector; + } + + //implements update method of Observer interface; + public void update(Observable o, Object arg){ + //only monitoring one queue (incoming from network) so doing no check on which Observable notified us. + synchronized(lock){ lock.notify(); //wake this thread } - } - + } + protected void finalize() { stop(); threadPool.shutdownThreads(); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-18 22:54:46
|
Revision: 62 Author: snowdog_ Date: 2006-04-18 15:54:17 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=62&view=rev Log Message: ----------- Reworked startOutboundMonitor method to ensure it will wait for a valid network service thread to become available before attempting to send outbound messages to clients. This prevents a race condition that could occur if a service thread is not available and which would result in dropped messages. Created new method (delegateMessageDelivery) to handle blocking service thread message hand off to help clarify code behavior. Modified Paths: -------------- trunk/src/openrpg2/common/core/network/NetworkServer.java Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-18 08:35:23 UTC (rev 61) +++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-18 22:54:17 UTC (rev 62) @@ -129,6 +129,13 @@ connectionState.announceDisconnection(connectionId); } + /** + * startOutboundMonitor creates a thread that monitors for new ORPGMessages + * being added to the outbound message queue. When a message arrives on + * the queue this thread is awakened and attempts to flush the queue through + * the network. This thread stays in a preempted state while not actively + * delivering messages. + */ private void startOutboundMonitor(){ monitorThread = new Thread(){ public void run(){ @@ -140,19 +147,7 @@ this.interrupted(); //clear inturrupted flag } while(outQueue.hasRemaining()){ - NetworkServiceThread nst = threadPool.getServiceThread(); - if (nst != null){ - //networkServiceThread available to handle request - ORPGMessage m = outQueue.pullMessage(); - int[] destId = m.getFinalRecipientList(); - for (int i = 0; i < destId.length; i++) { - //locate the NetworkConnection for the each destination id - if (clients.containsKey(new Integer(destId[i]))){ - NetworkConnection con = (NetworkConnection)clients.get(new Integer(destId[i])); - nst.serviceChannel(con, m.asNetworkMessage()); - } - } - } + delegateMessageDelivery(outQueue.pullMessage()); } } log.finer("Monitor thread terminating"); @@ -161,7 +156,37 @@ monitorThread.start(); } + /** + * delegateMessageDelivery is a helper method to the thread in startOutboundMonitor. + * This method pulls service threads from the network thread pool and tasks them to + * deliver copies of the supplied ORPGMessage to each client specified in the message's + * recipientList. This method may block during execution if no service threads are available. + * @param m the ORPGMessage to deliver. + */ + private void delegateMessageDelivery(ORPGMessage m){ + NetworkServiceThread nst=null; + + //get a message to handle and its associated recipient list + int[] destId = m.getFinalRecipientList(); + + //loop though recipient list + for (int i = 0; i < destId.length; i++) { + + //wait/block until a service thread becomes available (could be a while if network is very busy) + do { + nst = threadPool.getServiceThread(); + } while (nst == null); + + //locate the NetworkConnection for the each destination id and tell the service thread to handle the message + if (clients.containsKey(new Integer(destId[i]))){ + NetworkConnection con = (NetworkConnection)clients.get(new Integer(destId[i])); + nst.serviceChannel(con, m.asNetworkMessage()); + } + } + } + + /** * Initializes the NetworkServer object. * During initialization the server socket is bound to the InetSocketAddress (svrAddress) * and the NetworkThreadPool is generated to service the network connections. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-18 08:35:33
|
Revision: 61 Author: snowdog_ Date: 2006-04-18 01:35:23 -0700 (Tue, 18 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=61&view=rev Log Message: ----------- Continuing work on the Grouping and Message Routing code. Changes are fairly extensive and not yet complete but the should not impact other portions of the code base. Reworked group system to track client instances separate from group data (pass by reference meant all groups shared the clients group-centric data, this has been fixed). Reworked MessageAddress and ORPGMessage classes to allow a single ORPGMessage to contain multiple-client routing information that will result in copies of the same message sent out by the network.DefaultRelay has been updated to use new route addressing but currently requires a manual 'hack' to function as a bounce back relay until the message routing system is completed. Added two new targets to routing addresses (BROADCAST and SERVER) to simplify referencing all clients and messages that should be sent to the server only. Modified Paths: -------------- trunk/src/openrpg2/common/core/ORPGConstants.java trunk/src/openrpg2/common/core/ORPGMessage.java trunk/src/openrpg2/common/core/group/GroupClientModule.java trunk/src/openrpg2/common/core/group/GroupManager.java trunk/src/openrpg2/common/core/group/GroupMember.java trunk/src/openrpg2/common/core/group/GroupMessageConstants.java trunk/src/openrpg2/common/core/group/GroupServerModule.java trunk/src/openrpg2/common/core/network/NetworkServer.java trunk/src/openrpg2/common/core/route/MessageAddress.java trunk/src/openrpg2/server/core/modules/DefaultRelay.java Added Paths: ----------- trunk/src/openrpg2/common/core/group/GroupClient.java trunk/src/openrpg2/common/core/route/AddressToken.java Modified: trunk/src/openrpg2/common/core/ORPGConstants.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGConstants.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/ORPGConstants.java 2006-04-18 08:35:23 UTC (rev 61) @@ -21,6 +21,9 @@ package openrpg2.common.core; +import openrpg2.common.core.route.AddressToken; +import openrpg2.common.core.route.MessageAddress; + /** * OpenRPG2 application wide (global) constants. * @author snowdog @@ -33,13 +36,15 @@ static final public int OPENRPG2_MINOR_VERSION = 0; static final public int OPENRPG2_MICRO_VERSION = 1; - //ORPGMESSAGE HEADER CONSTANTS static final public String MESSAGE_TYPE = "_TYPE_"; static final public String MESSAGE_SUBTYPE = "_SUBT_"; static final public String MESSAGE_ORIGINATOR = "_ORID_"; // aka "From:" static final public String MESSAGE_DESTINATION = "_DEST_"; // aka "To:" + //ORPGMESSAGE ADDRESSING CONSTANTS + static final public MessageAddress TO_SERVER = new MessageAddress(new AddressToken(AddressToken.SERVER,0)); + //ORPGMESSAGE RESERVED TYPES //These are special message type identifiers that are part of the core implementation and are therefore reserved static final public String TYPE_NETWORK = "_NET_"; Modified: trunk/src/openrpg2/common/core/ORPGMessage.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGMessage.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/ORPGMessage.java 2006-04-18 08:35:23 UTC (rev 61) @@ -27,6 +27,7 @@ import java.util.Hashtable; import openrpg2.common.core.network.HeaderEncoder; import openrpg2.common.core.network.NetworkMessage; +import openrpg2.common.core.route.MessageAddress; @@ -48,9 +49,12 @@ /** numeric ID of the sending client (as assigned by server)*/ private int originatorId = 0; - /** numeric ID of the client that should recieve this message*/ - private int destinationId = 0; + /** MessageAddress of clients that should recieve this message*/ + private MessageAddress destination = null; + /** internal Client id array (set after filters applied to determine final recipient set */ + private int[] recipients = null; + /** Hashmap containing this messages header information */ private Hashtable header = null; @@ -103,12 +107,12 @@ handlerId = handler; } - public int getDestinationId(){ - return destinationId; + public MessageAddress getDestination(){ + return destination; } - public void setDestinationId( int dest){ - destinationId = dest; + public void setDestination(MessageAddress dest){ + destination = dest; } public int getOriginatorId(){ @@ -157,4 +161,18 @@ //return HeaderEncoder.encodeAsHumanReadable(header); } + + /** + * This method is called by the routing mechanisims after messaging filters have been applied + * to set a list of client ids that will recieve this message. <b>NOTE: This is an internal method and should not + * be called by programmers directly.</b> + * @param dests int array of client ids to receive a copy of this message. + */ + public void setFinalRecipientList( int [] dests){ + recipients = dests; + } + + public int[] getFinalRecipientList(){ + return recipients; + } } Added: trunk/src/openrpg2/common/core/group/GroupClient.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupClient.java (rev 0) +++ trunk/src/openrpg2/common/core/group/GroupClient.java 2006-04-18 08:35:23 UTC (rev 61) @@ -0,0 +1,88 @@ +/* + * GroupClient.java + * + * Author: snowdog + * Created: April 17, 2006, 12:39 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.group; + +/** + * This class represents client data that should remain consistent + * across all groups the client is invloved in. + * + * Data that should exist on a per-group basis (like display name + * and role settings) should be placed in GroupMember instead + * @author snowdog + * @see openrpg2.common.core.group.GroupMember + */ + +public class GroupClient { + + final static private String DEFAULTNAME = "Player-"; + private int networkId; + private String actualName = null; //used for user registration system if ever implemented + private String defaultDisplayName = null; //used as default display of name where ID number is not appropriate (optional) + private boolean serverModeratorFlag = false; + private boolean serverAdministratorFlag = false; + + /** Creates a new instance of GroupClient */ + public GroupClient(int clientId) { + networkId = clientId; + } + + + public boolean equals(int id){ + return isClient(id); + } + + public boolean equals(GroupClient m){ + return isClient(m.getNetworkId()); + } + + public boolean isClient(int n){ + if (networkId == n){ return true;} + return false; + } + + public int getNetworkId(){ + return networkId; + } + + public void setNetworkId( int id){ + networkId = id; + } + + public void setActualName(String name){ + actualName = name; + } + + public String getActualName(){ + if (actualName == null){return (DEFAULTNAME+networkId);} + return actualName; + } + + public void setDefaultDisplayName(String name){ + defaultDisplayName = name; + } + + public String getDefaultDisplayName(){ + if (defaultDisplayName == null){return (DEFAULTNAME+networkId);} + return defaultDisplayName; + } + +} Modified: trunk/src/openrpg2/common/core/group/GroupClientModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupClientModule.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/group/GroupClientModule.java 2006-04-18 08:35:23 UTC (rev 61) @@ -23,6 +23,8 @@ import openrpg2.common.core.ORPGConstants; import openrpg2.common.core.ORPGMessage; +import openrpg2.common.core.route.AddressToken; +import openrpg2.common.core.route.MessageAddress; import openrpg2.common.module.ClientLoadable; import openrpg2.common.module.NetworkedModule; @@ -112,5 +114,50 @@ } + /** + * Generates an empty ORPGMessage that will be routed by GroupModules + * As group messages are always between a client and server no extra + * routing information is required. + */ + private ORPGMessage createGroupMessage(){ + ORPGMessage msg = new ORPGMessage(); + msg.setHeader(ORPGConstants.MESSAGE_TYPE, ORPGConstants.TYPE_GROUP); + msg.setDestination(ORPGConstants.TO_SERVER); + return msg; + } + + /** + * Generates an ORPGMessage that contains a request for the server to create a new group for this client. + */ + public ORPGMessage getMessageCreateGroupRequest(String groupName, String shortDescription, String longDescription){ + ORPGMessage msg = createGroupMessage(); + msg.setHeader(GroupMessageConstants.HEADER_OP, GroupMessageConstants.OP_GROUP); + msg.setHeader(GroupMessageConstants.HEADER_SUB_OP, GroupMessageConstants.SUB_OP_ADD); + msg.setHeader(GroupMessageConstants.GROUP_NAME, groupName); + msg.setHeader(GroupMessageConstants.GROUP_SHORT_DESCRIPTION, shortDescription); + msg.setHeader(GroupMessageConstants.GROUP_LONG_DESCRIPTION, longDescription); + return msg; + } + + public ORPGMessage getMessageJoinGroup(int groupId){ + ORPGMessage msg = createGroupMessage(); + //TODO + return msg; + } + + + public ORPGMessage getMessageDropGroup(int groupId){ + ORPGMessage msg = createGroupMessage(); + //TODO + return msg; + } + + + public ORPGMessage getMessageGroupUpdateRequest(){ + ORPGMessage msg = createGroupMessage(); + //TODO + return msg; + } + } Modified: trunk/src/openrpg2/common/core/group/GroupManager.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-18 08:35:23 UTC (rev 61) @@ -35,7 +35,7 @@ * and tracking of logical client groupings. It also helps facilitate * message routing by providing reference for which clients should get * messages based on group associations as well as client role within - * a specific group. + * a specific group. * * @author Snowdog */ @@ -44,6 +44,7 @@ public static final int LOBBY_ID = 1; private int nextGroupId = LOBBY_ID +1; Hashtable groupList = new Hashtable(); + Hashtable clientList = new Hashtable(); private Logger log = Logger.getLogger(this.getClass().getName()); /** Creates a new instance of GroupManager */ @@ -55,22 +56,15 @@ } public int addGroup(){ - boolean res = addGroup(nextGroupId, null); - if (res){ - nextGroupId++; - return nextGroupId-1; - }else{ - return 0; - } + return addGroup(null); } public int addGroup(String groupName){ - boolean res = addGroup(nextGroupId, groupName); - if (res){ + if ( addGroup(nextGroupId, groupName)){ nextGroupId++; return nextGroupId-1; }else{ - return 0; + return -1; } } @@ -97,8 +91,15 @@ return true; } - private synchronized boolean addClientToGroup(int groupId, GroupMember m){ + private synchronized boolean addClient(GroupClient clientReference){ + Integer cid = new Integer(clientReference.getNetworkId()); + clientList.put(cid,clientReference); + return false; + } + + public synchronized boolean addMemberToGroup(int groupId, GroupMember m){ Integer gid = new Integer(groupId); + if (!clientList.containsKey(new Integer(m.getNetworkId()))){ return false; } //sanity check if(groupList.containsKey(gid)){ Group group = (Group)groupList.get(gid); group.add(m); @@ -107,25 +108,16 @@ return false; } - public synchronized boolean insertClientIntoGroup(int clientId, int groupId){ + public synchronized boolean addMemberToGroup(int groupId, int clientId){ Integer gid = new Integer(groupId); - if (!groupList.containsKey(gid)){ return false; } //sanity check - - GroupMember m = null; - try{ - m = locateMemberReference(clientId); - }catch(InvalidMemberException e){ - return false; - } - Group g = ((Group)groupList.get(gid)); - if( g.hasMember(clientId)){ - return false; - } - g.add(m); - return true; + Integer cid = new Integer(clientId); + if (!clientList.containsKey(cid)){ return false; } //sanity check + GroupClient client = (GroupClient) clientList.get(cid); + GroupMember m = new GroupMember(client); + return addMemberToGroup(groupId, m); } - public synchronized boolean changeClientGroup(int clientId, int fromGroupId, int toGroupId){ + public synchronized boolean changeMemberGroup(int clientId, int fromGroupId, int toGroupId){ Integer fgid = new Integer(fromGroupId); Integer tgid = new Integer(toGroupId); if (!groupList.containsKey(fgid)){ return false; } //sanity check @@ -203,33 +195,44 @@ throw new InvalidMemberException("No such member -> "+id); } - private synchronized GroupMember locateMemberReference(int id) throws InvalidMemberException{ - Enumeration groups = groupList.elements(); - while (groups.hasMoreElements()){ - Group g = (Group)groups.nextElement(); - if ( g.hasMember(id)){ - return g.getMemberWithNullReturn(id); - } + private synchronized GroupClient locateClientReference(int id) throws InvalidMemberException{ + Integer i = new Integer(id); + if (clientList.containsKey(i)){ + return (GroupClient) clientList.get(i); } throw new InvalidMemberException("No such member -> "+id); } public synchronized void clientConnect(int id){ - GroupMember m = new GroupMember(id); - addClientToGroup(LOBBY_ID, m); + GroupClient c = new GroupClient(new Integer(id)); + addClient(c); + GroupMember m = new GroupMember(c); + addMemberToGroup(LOBBY_ID, m); } public synchronized void clientDisconnect(int id){ + //remove client references from group Enumeration groups = groupList.elements(); while (groups.hasMoreElements()){ Group g = (Group)groups.nextElement(); - g.remove(id); + g.remove(new Integer(id)); checkGroupRemovable(g.getGroupId()); } + //prune out client from clientList + clientList.remove(id); + } + public void DEBUG_PRINTCLIENTLIST(){ + Enumeration clients = clientList.elements(); + while (clients.hasMoreElements()){ + GroupClient c = (GroupClient)clients.nextElement(); + System.out.println("Client #"+c.getNetworkId()+" "+c.getActualName()+" ("+c.getDefaultDisplayName()+")"); + } + } + public void DEBUG_PRINTGROUPTREE(){ Enumeration groups = groupList.elements(); while (groups.hasMoreElements()){ @@ -238,17 +241,44 @@ Enumeration members = g.getMembers(); while( members.hasMoreElements()){ GroupMember m = (GroupMember)members.nextElement(); - System.out.print(m.getDisplayName()+"("+m.getNetworkId()+")"); + MemberRole r=null; + try { + r = g.getRole(m); + } catch (InvalidMemberException ex) { + ex.printStackTrace(); + } + String role; + if (r.isGM()){role = "[GM] ";} + else if (r.isGhost()){role="[G] ";} + else if (r.isLurker()){role="[L] ";} + else{ role="[P] ";} + System.out.print(role+m.getDisplayName()+"("+m.getNetworkId()+")"); if (members.hasMoreElements()){ System.out.print(", ");} } System.out.println(""); } } - public GroupMember getClient(int id)throws InvalidMemberException{ - return locateMemberReference( id) ; + public GroupClient getClient(int id)throws InvalidMemberException{ + return locateClientReference(id) ; } + /** + * Creates a new GroupMember object tied to a specific client id. + * + * @return GroupMember object that is not bound to a specific group. If clientId is invalid null will be returned instead + * @param clientId client id number + */ + public GroupMember generateNewGroupMember(int clientId) { + GroupClient gc; + try { + gc = locateClientReference(clientId); + } catch (InvalidMemberException ex) { + gc = null; + } + return new GroupMember(gc); + } + public Group getGroup(int id) throws InvalidGroupException{ Integer gid = new Integer(id); if ( !groupList.containsKey(gid)){ @@ -271,7 +301,7 @@ log.warning("Network Reported Unknown Client State. State change ignored."); } } -} + } public GroupClientModule getGroupClientModule(){ return new GroupClientModule(this); Modified: trunk/src/openrpg2/common/core/group/GroupMember.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupMember.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/group/GroupMember.java 2006-04-18 08:35:23 UTC (rev 61) @@ -23,57 +23,53 @@ /** * The GroupMember class defines the characteristics of a single group - * member. Such information contains real and display names as well as - * the member's role within a given group. + * member. This class contains only information specific to a single + * group for a given client. * + * Group information specific to the client and outside of 'group scope' + * should be placed in GroupClient instead. + * @see openrpg2.common.core.group.GroupClient * @author Snowdog */ public class GroupMember { final static private String DEFAULTNAME = "Player-"; - private int networkId; - private String actualName = null; //used for user registration system if ever implemented + private GroupClient client = null; private String displayName = null; //used for display of name where ID number is not appropriate (optional) - private boolean serverModeratorFlag = false; - private boolean serverAdministratorFlag = false; + /** Creates a new instance of GroupMember */ - public GroupMember() { + // public GroupMember() { + //} + + public GroupMember(GroupClient clientReference){ + client = clientReference; } - public GroupMember(int id){ - networkId = id; + public void setGroupClient(GroupClient clientReference){ + client = clientReference; } public boolean equals(int id){ - return isClient(id); + return client.isClient(id); } public boolean equals(GroupMember m){ - return isClient(m.getNetworkId()); + return client.isClient(m.getNetworkId()); } public boolean isClient(int n){ - if (networkId == n){ return true;} - return false; + return client.isClient(n); } public int getNetworkId(){ - return networkId; + return client.getNetworkId(); } - public void setNetworkId( int id){ - networkId = id; - } - - public void setActualName(String name){ - actualName = name; - } public String getActualName(){ - if (actualName == null){return (DEFAULTNAME+networkId);} - return actualName; + return client.getActualName(); } public void setDisplayName(String name){ @@ -81,8 +77,11 @@ } public String getDisplayName(){ - if (displayName == null){return (DEFAULTNAME+networkId);} - return displayName; + if (displayName != null){ + return displayName; + }else{ + return client.getDefaultDisplayName(); + } } } Modified: trunk/src/openrpg2/common/core/group/GroupMessageConstants.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupMessageConstants.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/group/GroupMessageConstants.java 2006-04-18 08:35:23 UTC (rev 61) @@ -40,6 +40,17 @@ public final static int SUB_OP_MOVE = 4; public final static int SUB_OP_UPDATE = 5; + //group message constants + public final static String GROUP_NAME = "GN"; + public final static String GROUP_SHORT_DESCRIPTION = "SD"; + public final static String GROUP_LONG_DESCRIPTION = "LD"; + + //role message constants + public final static String ROLE = "R"; + + + + /** Creates a new instance of GroupMessageConstants */ public GroupMessageConstants() { } Modified: trunk/src/openrpg2/common/core/group/GroupServerModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupServerModule.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/group/GroupServerModule.java 2006-04-18 08:35:23 UTC (rev 61) @@ -23,6 +23,8 @@ import openrpg2.common.core.ORPGConstants; import openrpg2.common.core.ORPGMessage; +import openrpg2.common.core.route.MessageAddress; +import openrpg2.common.core.route.AddressToken; import openrpg2.common.module.NetworkedModule; import openrpg2.common.module.ServerLoadable; @@ -79,7 +81,7 @@ private void handleGroupMessage(ORPGMessage msg){ int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_SUB_OP)); switch(operation){ - case(GroupMessageConstants.SUB_OP_ADD):{break; } //add a new group + case(GroupMessageConstants.SUB_OP_ADD):{processCreateGroupRequest(msg); break; } //add a new group case(GroupMessageConstants.SUB_OP_DROP):{break; } //remove an existing group case(GroupMessageConstants.SUB_OP_ALTER):{break; } //change group info case(GroupMessageConstants.SUB_OP_UPDATE):{break; } //refresh/replace group info @@ -103,6 +105,67 @@ } } + /** + *processCreateGroupRequest handles requests made by clients for the server + *to create a new group. Server will automatically make the requesting client + *a GM within the newly created group. + */ + private void processCreateGroupRequest(ORPGMessage msg){ + //Gather information from message + int requestingClient = msg.getOriginatorId(); + String name = msg.getHeader(GroupMessageConstants.GROUP_NAME); + String sdesc = msg.getHeader(GroupMessageConstants.GROUP_SHORT_DESCRIPTION); + String ldesc = msg.getHeader(GroupMessageConstants.GROUP_LONG_DESCRIPTION); + + //create the room for the client + int g = groupManager.addGroup(name); + if(g <= groupManager.LOBBY_ID){ //bailout with warning if no group created. + log.warning("Group add failed for client "+requestingClient); + return; + } + + //attempt to update group information and add client to group as GM + try { + Group gr = groupManager.getGroup(g); + gr.setShortDescription(sdesc); + gr.setLongDescription(ldesc); + try { + GroupClient c = groupManager.getClient(requestingClient); + GroupMember m = new GroupMember(c); + gr.add(m); + gr.setRole(m,Role.ROLE_GM); + } catch (InvalidMemberException e) { + log.warning(e.getMessage()); + } + + } catch (InvalidGroupException ex) { + log.warning(ex.getMessage()); + ex.printStackTrace(); + } + + //notify all clients of the group change. + //TODO sendGroupAnnounce( /*TO ALL CLIENTS*/ ); + + } + private void sendGroupAnnounce(int groupId){ + MessageAddress sendTo = new MessageAddress(); + sendTo.append(new AddressToken(AddressToken.BROADCAST,0)); + ORPGMessage msg = createGroupMessage(); + msg.setDestination(sendTo); + + //TODO: data should include group member list and data to duplicate it on client side. + } + /** + * Generates an empty ORPGMessage that will be routed by GroupModules + * As group messages are always between a client and server + */ + + private ORPGMessage createGroupMessage(){ + ORPGMessage msg = new ORPGMessage(); + msg.setHeader(ORPGConstants.MESSAGE_TYPE, ORPGConstants.TYPE_GROUP); + return msg; + } + } \ No newline at end of file Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-18 08:35:23 UTC (rev 61) @@ -42,9 +42,9 @@ /** - * Network Server. This class represents the interface between all network + * Network Server. This class represents the interface between all network * functions of the OpenRPG server and the remainder of the application. - * This is intended to be a black-box object such that network operations are + * This is intended to be a black-box object such that network operations are * wholely contained and implemented within this object. All interaction with * the network functions of OpenRPG should occure though this objects API. * @author snowdog @@ -115,9 +115,9 @@ protected boolean insert(NetworkConnection newClient){ //TODO: add error checking to prevent replacement of clientId keys int clientId = newClient.getId(); - synchronized(clients){ + synchronized(clients){ clients.put(new Integer(clientId), newClient); - } + } connectionState.announceConnection(clientId); return true; } @@ -134,35 +134,35 @@ public void run(){ while(runFlag){ try{ - synchronized(monitorLock){ monitorLock.wait(); } + synchronized(monitorLock){ monitorLock.wait(); } }catch(InterruptedException e){ e.printStackTrace(); this.interrupted(); //clear inturrupted flag } while(outQueue.hasRemaining()){ NetworkServiceThread nst = threadPool.getServiceThread(); - if (nst != null){ - //networkServiceThread available to handle request - ORPGMessage m = outQueue.pullMessage(); - int destId = m.getDestinationId(); - //System.out.println("[DEBUG] NetworkServer.monitorThread handling message for "+destId); - //locate the NetworkConnection for the destination id - if (clients.containsKey(new Integer(destId))){ - NetworkConnection con = (NetworkConnection)clients.get(new Integer(destId)); - nst.serviceChannel(con, m.asNetworkMessage()); - } - - } + if (nst != null){ + //networkServiceThread available to handle request + ORPGMessage m = outQueue.pullMessage(); + int[] destId = m.getFinalRecipientList(); + for (int i = 0; i < destId.length; i++) { + //locate the NetworkConnection for the each destination id + if (clients.containsKey(new Integer(destId[i]))){ + NetworkConnection con = (NetworkConnection)clients.get(new Integer(destId[i])); + nst.serviceChannel(con, m.asNetworkMessage()); + } + } + } } } - log.finer("Monitor thread terminating"); + log.finer("Monitor thread terminating"); } }; monitorThread.start(); } /** - * Initializes the NetworkServer object. + * Initializes the NetworkServer object. * During initialization the server socket is bound to the InetSocketAddress (svrAddress) * and the NetworkThreadPool is generated to service the network connections. * @return true if initialization completed ok @@ -198,7 +198,7 @@ return true; } - + /** * starts the NetworkServer handling messages and accepting new connections */ @@ -236,14 +236,14 @@ //networkServiceThread available to handle request nst.serviceChannel(k); }else{ - // if no NetworkServiceThreads are currently available to handle - // the key it will be ignored and handled on a later cycle though - // the selector as the key will still be in the selected set. - //because this thread can run much faster than the servicethreads - //sleep for a short period of time to allow service threads to complete - try{ - sleep(100); - }catch(InterruptedException ie){ } + // if no NetworkServiceThreads are currently available to handle + // the key it will be ignored and handled on a later cycle though + // the selector as the key will still be in the selected set. + //because this thread can run much faster than the servicethreads + //sleep for a short period of time to allow service threads to complete + try{ + sleep(100); + }catch(InterruptedException ie){ } } } } @@ -268,21 +268,21 @@ * stops the network functions of the NetworkServer */ public void stopServer(){ - runFlag=false; - threadPool.shutdownThreads(); - synchronized(monitorLock){ - monitorLock.notify(); //let the outbound monitor know a message is ready - } - try{ Thread.sleep(1000); }//wait 2 seconds to let threads finish closing - catch(InterruptedException e){} - log.finer("[DEBUG] killing connections"); - Enumeration en = clients.keys(); - while(en.hasMoreElements()){ - Integer i = (Integer)en.nextElement(); - NetworkConnection n = (NetworkConnection)clients.get(i); - n.disconnect(); - } - + runFlag=false; + threadPool.shutdownThreads(); + synchronized(monitorLock){ + monitorLock.notify(); //let the outbound monitor know a message is ready + } + try{ Thread.sleep(1000); }//wait 2 seconds to let threads finish closing + catch(InterruptedException e){} + log.finer("[DEBUG] killing connections"); + Enumeration en = clients.keys(); + while(en.hasMoreElements()){ + Integer i = (Integer)en.nextElement(); + NetworkConnection n = (NetworkConnection)clients.get(i); + n.disconnect(); + } + } /** @@ -291,7 +291,7 @@ */ public void sendMessage(ORPGMessage msg){ outQueue.putMessage(msg); - synchronized(monitorLock){ + synchronized(monitorLock){ monitorLock.notify(); //let the outbound monitor know a message is ready } } @@ -303,7 +303,7 @@ protected void putMessage(ORPGMessage msg){ inQueue.putMessage(msg); } - + public Observable addMessageQueueObserver(Observer o){ inQueue.addObserver(o); return outQueue; //return reference to object for comparison only in case more than one observable is being monitored. @@ -316,7 +316,7 @@ public int pendingOutboundMessages(){ return outQueue.size(); } - + public boolean hasClientId(int clientId){ Integer id = new Integer(clientId); if (clients.containsKey(id)){ @@ -378,7 +378,7 @@ /** * Required for implementation of NetworkModuleProvider interface. - * + * */ public NetworkedModule getNetworkModule(){ return new NetworkServerModule(this); Added: trunk/src/openrpg2/common/core/route/AddressToken.java =================================================================== --- trunk/src/openrpg2/common/core/route/AddressToken.java (rev 0) +++ trunk/src/openrpg2/common/core/route/AddressToken.java 2006-04-18 08:35:23 UTC (rev 61) @@ -0,0 +1,254 @@ +/* + * MessageAddress.java + * + * Author: Snowdog + * Created: March 27, 2006, 4:30 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.route; + +/** + * handles addressing messages + * @author Snowdog + */ +public class AddressToken { + + /** Constant target: ALL - send to all clients (in room #) */ + final static public char ALL = 'A'; + /** Constant target: GM - send to all clients with GM role (in room #) */ + final static public char GM = 'G'; + /** Constant target: PLAYERS - send to all clients with Player role (in room #) */ + final static public char PLAYERS = 'P'; + /** Constant target: LURKERS - send to all clients with Lurker role (in room #) */ + final static public char LURKERS = 'L'; + /** Constant target: INVISIBLES - send to all clients who have the invisible role (in room #) */ + final static public char INVISIBLES = 'I'; + /** Constant target: SELF - send back to message originator (in room #) */ + final static public char SELF = 'S'; + /** Constant target: CLIENT - send to specific client (with id #) */ + final static public char CLIENT = 'C'; + /** Constant target: NOT - logical not, exclude flag */ + final static public char NOT = '!'; + /** Constant target: BROADCAST - send to all clients on the server (id number ignored when using this target) */ + final static public char BROADCAST = 'B'; + /** Constant target: SERVER - send to server only (do not relay to clients even if message not understood) */ + final static public char SERVER = 'X'; + + + /** exclude. When true this address will be excluded from message receipt. */ + private boolean exclude; + /** target. The target of this address. */ + private char target; + /** id. The identifier for client or group # to use in conjunction with the target. */ + private int id; + + /** + * Creates a new MessageAddress object that is by default set to deliver to a Client with an undeliverable ID. + */ + public AddressToken() { + clear(); + } + + /** + * Creates a new instance of MessageAddress configured to deliver a message to a client with the given id number. + * @param id Client ID to deliver message to. + */ + public AddressToken(int id) { + clear(); + this.id = id; + } + + /** + * Creates a new instance of MessageAddress configured to deliver a message to a client with the given id number and optional exclusion flag. + * @param id Client ID to deliver to or exclude from delivery depending on exclude flag. + * @param exclude If true the client will be excluded from message delivery. + */ + public AddressToken(int id, boolean exclude) { + clear(); + this.id = id; + this.exclude = exclude; + } + /** + * Creates a new instance of MessageAddress with a specific target and id. + * Internal exclude flag is set to false automatically. + * @param target char. Target of message. See defined constants in MessageAddress + * @param id The id number of the client or group to identify the target. + */ + public AddressToken(char target, int id) { + clear(); + if (isValidTarget(target)){ + this.target = target; + } + this.id = id; + } + /** + * Creates a new instance of MessageAddress + * @param target char. Target of message. See defined constants in MessageAddress + * @param id The id number of the client or group to identify the target. + * @param exclude exclude target (logical not) from message delivery when true + */ + public AddressToken(char target, int id, boolean exclude) { + if (isValidTarget(target)){ + this.target = target; + } + this.id = id; + this.exclude = exclude; + } + + /** + * Sets the internal excluded flag state. + * The excluded flag operates like a logical 'not' for this address. + * Any address object with its excluded flag set will cause its target + * to be excluded from composite messageAddresses. + * @param exclude true, set the logical not and prevent this target from being sent a message. + * false allows normal message addressing function. + */ + public void setExcluded(boolean exclude){ + this.exclude = exclude; + } + + /** + * Sets the target of the address. See predefined target constants in MessageAddress + * @param target A single char representing the addressing target of this message + * @return boolean. True if target setting was valid, false if target is not valid + */ + public boolean setTarget(char target){ + if (isValidTarget(target)){ + this.target = target; + return true; + } + return false; + } + + /** + * Sets the client or group id number. + * @param id client or group id 'target' for this address object + */ + public void setId(int id){ + this.id = id; + } + + /** + * Generates an encoded address string for this object + * @return encoded message address String. + */ + public String toString(){ + StringBuffer temp = new StringBuffer(); + if(exclude){ + temp.append(NOT); + } + temp.append(target); + temp.append(id); + return temp.toString(); + } + + + + /** + * resets the addressing information in this object to its default state. + */ + public void clear(){ + exclude = false; + target = CLIENT; + id = 0; + } + + /** + * Internal method to validate target constants + * @param target char. Target of message. See defined constants in MessageAddress + * @return boolean. true if target is valid. + */ + private boolean isValidTarget(char target){ + if ( target == BROADCAST){return true;} + if ( target == SERVER){return true;} + if ( target == ALL ){return true;} + if ( target == GM ){return true;} + if ( target == PLAYERS ){return true;} + if ( target == LURKERS ){return true;} + if ( target == INVISIBLES ){return true;} + if ( target == SELF ){return true;} + if ( target == CLIENT ){return true;} + return false; + } + + /** + * Returns a human readable address string representation of this object. + * Useful for debugging addressing issues. + * @return a human readable address string. + */ + public String getHumanReadableAddress(){ + String temp = "Address: "; + if ( target == BROADCAST ){temp += "To BROADCAST (all clients)"; return temp;} + if ( target == SERVER){ temp += "SERVER only"; return temp; } + if (exclude){ temp += "Exclude "; } else {temp += "To ";} + if ( target == ALL ){temp += "ALL in group #";} else if ( target == CLIENT ){temp += "CLIENT #";} else if ( target == GM ){temp += "GMs in group #";} else if ( target == PLAYERS ){temp += "PLAYERS in group #";} else if ( target == LURKERS ){temp += "LURKERS in group #";} else if ( target == INVISIBLES ){temp += "INVISIBLES in group #";} else if ( target == SELF ){temp += "SELF in group # ";} else{ temp += "[invalid address]"; return temp;} + temp += id; + return temp; + + } + + + /** + * convert() serves as the counterpart to the encode() method. + * It converts address tokens as created by encode() back into MessageAddress objects. + * This is a static method. + * @param addressToken A single address token as generated by encode() or toString() + * @throws openrpg2.common.core.route.InvalidMessageTargetException Thrown when errors occure while converting the message address + * @return returns a MessageAddress object representing the address token. + */ + static public AddressToken convert(String addressToken) throws InvalidMessageTargetException { + AddressToken temp = new AddressToken(); + int pos = 0; + if (addressToken.charAt(pos) == BROADCAST){ + temp.setTarget(BROADCAST); + temp.setId(0); + return temp; + } + if (addressToken.charAt(pos) == SERVER){ + temp.setTarget(SERVER); + temp.setId(0); + return temp; + } + if (addressToken.charAt(pos) == NOT){ + temp.setExcluded(true); + pos++; + } + char directive = addressToken.charAt(pos); + if (!temp.setTarget(directive)){ + throw new InvalidMessageTargetException("Invalid routing flag: '"+directive+"'"); + } + pos++; + int h = 0; + try{ + h = Integer.parseInt(addressToken.substring(pos)); + }catch( NumberFormatException e){ + throw new InvalidMessageTargetException("NumberFormatException could not parse ID #"); + } + temp.setId(h); + return temp; + } + + /** + * A static wrapper method for the toString() method. + * @param m A MessageAddress object to extract the address token from. + * @return A String representing the address token of m + */ + static public String encode( AddressToken m){ + return m.toString(); + } + +} Modified: trunk/src/openrpg2/common/core/route/MessageAddress.java =================================================================== --- trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/common/core/route/MessageAddress.java 2006-04-18 08:35:23 UTC (rev 61) @@ -1,243 +1,81 @@ -/* - * MessageAddress.java - * - * Author: Snowdog - * Created: March 27, 2006, 4:30 PM - * - * ==================================================================== - * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License on www.gnu.org for more details. - * ==================================================================== - */ - -package openrpg2.common.core.route; - -/** - * handles addressing messages - * @author Snowdog - */ -public class MessageAddress { - - /** Constant target: ALL - send to all clients (in room #) */ - final static public char ALL = 'A'; - /** Constant target: GM - send to all clients with GM role (in room #) */ - final static public char GM = 'G'; - /** Constant target: PLAYERS - send to all clients with Player role (in room #) */ - final static public char PLAYERS = 'P'; - /** Constant target: LURKERS - send to all clients with Lurker role (in room #) */ - final static public char LURKERS = 'L'; - /** Constant target: INVISIBLES - send to all clients who have the invisible role (in room #) */ - final static public char INVISIBLES = 'I'; - /** Constant target: SELF - send back to message originator (in room #) */ - final static public char SELF = 'S'; - /** Constant target: CLIENT - send to specific client (with id #) */ - final static public char CLIENT = 'C'; - /** Constant target: NOT - logical not, exclude flag */ - final static public char NOT = '!'; - - /** exclude. When true this address will be excluded from message receipt. */ - private boolean exclude; - /** target. The target of this address. */ - private char target; - /** id. The identifier for client or group # to use in conjunction with the target. */ - private int id; - - /** - * Creates a new MessageAddress object that is by default set to deliver to a Client with an undeliverable ID. - */ - public MessageAddress() { - clear(); - } - - /** - * Creates a new instance of MessageAddress configured to deliver a message to a client with the given id number. - * @param id Client ID to deliver message to. - */ - public MessageAddress(int id) { - clear(); - this.id = id; - } - - /** - * Creates a new instance of MessageAddress configured to deliver a message to a client with the given id number and optional exclusion flag. - * @param id Client ID to deliver to or exclude from delivery depending on exclude flag. - * @param exclude If true the client will be excluded from message delivery. - */ - public MessageAddress(int id, boolean exclude) { - clear(); - this.id = id; - this.exclude = exclude; - } - /** - * Creates a new instance of MessageAddress with a specific target and id. - * Internal exclude flag is set to false automatically. - * @param target char. Target of message. See defined constants in MessageAddress - * @param id The id number of the client or group to identify the target. - */ - public MessageAddress(char target, int id) { - clear(); - if (isValidTarget(target)){ - this.target = target; - } - this.id = id; - } - /** - * Creates a new instance of MessageAddress - * @param target char. Target of message. See defined constants in MessageAddress - * @param id The id number of the client or group to identify the target. - * @param exclude exclude target (logical not) from message delivery when true - */ - public MessageAddress(char target, int id, boolean exclude) { - if (isValidTarget(target)){ - this.target = target; - } - this.id = id; - this.exclude = exclude; - } - - /** - * Sets the internal excluded flag state. - * The excluded flag operates like a logical 'not' for this address. - * Any address object with its excluded flag set will cause its target - * to be excluded from composite messageAddresses. - * @param exclude true, set the logical not and prevent this target from being sent a message. - * false allows normal message addressing function. - */ - public void setExcluded(boolean exclude){ - this.exclude = exclude; - } - - /** - * Sets the target of the address. See predefined target constants in MessageAddress - * @param target A single char representing the addressing target of this message - * @return boolean. True if target setting was valid, false if target is not valid - */ - public boolean setTarget(char target){ - if (isValidTarget(target)){ - this.target = target; - return true; - } - return false; - } - - /** - * Sets the client or group id number. - * @param id client or group id 'target' for this address object - */ - public void setId(int id){ - this.id = id; - } - - /** - * Generates an encoded address string for this object - * @return encoded message address String. - */ - public String toString(){ - StringBuffer temp = new StringBuffer(); - if(exclude){ - temp.append(NOT); - } - temp.append(target); - temp.append(id); - return temp.toString(); - } - - - - /** - * resets the addressing information in this object to its default state. - */ - public void clear(){ - exclude = false; - target = CLIENT; - id = 0; - } - - /** - * Internal method to validate target constants - * @param target char. Target of message. See defined constants in MessageAddress - * @return boolean. true if target is valid. - */ - private boolean isValidTarget(char target){ - if ( target == ALL ){return true;} - if ( target == GM ){return true;} - if ( target == PLAYERS ){return true;} - if ( target == LURKERS ){return true;} - if ( target == INVISIBLES ){return true;} - if ( target == SELF ){return true;} - if ( target == CLIENT ){return true;} - return false; - } - - /** - * Returns a human readable address string representation of this object. - * Useful for debugging addressing issues. - * @return a human readable address string. - */ - public String getHumanReadableAddress(){ - String temp; - if (exclude){ temp = "Address: Exclude "; } - else {temp = "Address: To ";} - if ( target == ALL ){temp += "ALL in group #";} - else if ( target == CLIENT ){temp += "CLIENT #";} - else if ( target == GM ){temp += "GMs in group #";} - else if ( target == PLAYERS ){temp += "PLAYERS in group #";} - else if ( target == LURKERS ){temp += "LURKERS in group #";} - else if ( target == INVISIBLES ){temp += "INVISIBLES in group #";} - else if ( target == SELF ){temp += "SELF in group # ";} - else{ temp += "[invalid address]"; return temp;} - temp += id; - return temp; - - } - - - /** - * convert() serves as the counterpart to the encode() method. - * It converts address tokens as created by encode() back into MessageAddress objects. - * This is a static method. - * @param addressToken A single address token as generated by encode() or toString() - * @throws openrpg2.common.core.route.InvalidMessageTargetException Thrown when errors occure while converting the message address - * @return returns a MessageAddress object representing the address token. - */ - static public MessageAddress convert(String addressToken) throws InvalidMessageTargetException { - MessageAddress temp = new MessageAddress(); - int pos = 0; - if (addressToken.charAt(pos) == NOT){ - temp.setExcluded(true); - pos++; - } - char directive = addressToken.charAt(pos); - if (!temp.setTarget(directive)){ - throw new InvalidMessageTargetException("Invalid routing flag: '"+directive+"'"); - } - pos++; - int h = 0; - try{ - h = Integer.parseInt(addressToken.substring(pos)); - }catch( NumberFormatException e){ - throw new InvalidMessageTargetException("NumberFormatException could not parse ID #"); - } - temp.setId(h); - return temp; - } - - /** - * A static wrapper method for the toString() method. - * @param m A MessageAddress object to extract the address token from. - * @return A String representing the address token of m - */ - static public String encode( MessageAddress m){ - return m.toString(); - } - -} +/* + * MessageAddress.java + * + * Author: Snowdog + * Created: April 17, 2006, 11:41 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.route; + +import java.util.Enumeration; +import java.util.StringTokenizer; +import java.util.Vector; + +/** + * + * @author Snowdog + */ +public class MessageAddress { + + static final String ADDRESS_TOKEN_SEPARATOR = ":"; + Vector address = new Vector(); + + /** Creates a new instance of MessageAddress */ + public MessageAddress() { + } + + public MessageAddress(AddressToken token){ + append(token); + } + + public boolean append(AddressToken token){ + return address.add(token); + } + + public void clear(){ + Vector address = new Vector(); + } + + public Enumeration convert(String addressString){ + clear(); + AddressToken t = null; + StringTokenizer tok = new StringTokenizer(addressString, ADDRESS_TOKEN_SEPARATOR); + while(tok.hasMoreTokens()){ + try { + t = AddressToken.convert(tok.nextToken()); + address.add(t); + } catch (InvalidMessageTargetException ex) { + //ignore (discard) invalid or malformed address tokens + } + } + return address.elements(); + } + + public String encode(){ + return toString(); + } + + public String toString(){ + StringBuffer buf = new StringBuffer(); + Enumeration list = address.elements(); + while( list.hasMoreElements()){ + AddressToken t = (AddressToken)list.nextElement(); + buf.append( AddressToken.encode(t) ) ; + } + return buf.toString(); + } +} Modified: trunk/src/openrpg2/server/core/modules/DefaultRelay.java =================================================================== --- trunk/src/openrpg2/server/core/modules/DefaultRelay.java 2006-04-12 21:20:18 UTC (rev 60) +++ trunk/src/openrpg2/server/core/modules/DefaultRelay.java 2006-04-18 08:35:23 UTC (rev 61) @@ -23,6 +23,8 @@ import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.engine.ModuleCommunicationException; +import openrpg2.common.core.route.MessageAddress; +import openrpg2.common.core.route.AddressToken; import openrpg2.common.module.NetworkedModule; import openrpg2.common.module.ServerLoadable; @@ -55,7 +57,16 @@ } //relay message back to originator - msg.setDestinationId(msg.getOriginatorId()); + MessageAddress a = new MessageAddress(); + a.append(new AddressToken(AddressToken.CLIENT,msg.getOriginatorId())); + msg.setDestination(a); + //---------------- temporary code start ---------------------------- + // Remove this code once the routing/addressing system is complete + // Manually forcing bounce to sender behavior for testing purposes + int[] sendto = {msg.getOriginatorId()}; + msg.setFinalRecipientList(sendto); + // + //--------------- temporary code end ------------------------- try{ modCom.sendToNetwork(msg); }catch (ModuleCommunicationException e){ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-12 21:20:23
|
Revision: 60 Author: snowdog_ Date: 2006-04-12 14:20:18 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=60&view=rev Log Message: ----------- Added look and feel submenu to developer menu (temporary placement until a better home can be found for the look and feel option). Modified Paths: -------------- trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java Modified: trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java =================================================================== --- trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java 2006-04-12 18:29:09 UTC (rev 59) +++ trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java 2006-04-12 21:20:18 UTC (rev 60) @@ -26,7 +26,12 @@ import java.util.Hashtable; import java.util.logging.Logger; +import javax.swing.ButtonGroup; +import javax.swing.JMenu; import javax.swing.JMenuItem; +import javax.swing.JRadioButtonMenuItem; +import javax.swing.SwingUtilities; +import javax.swing.UIManager; import openrpg2.common.core.gui.ManageableGUI; import openrpg2.common.core.gui.GUIManagerCallback; @@ -37,23 +42,22 @@ */ public class MDIManager implements ManageableGUI, ActionListener { - private Hashtable moduleGUIs; //Holds all the JPanels keyed by Module name + private Hashtable moduleGUIs; //Holds all the JPanels keyed by Module name private MDIFrame mainMDIFrame; /** Callback reference to the GUIManager for MenuManager Access */ private GUIManagerCallback guiManagerRef; private Logger log = Logger.getLogger(this.getClass().getName()); /** - * Creates a new instance of MDIManager + * Creates a new instance of MDIManager */ public MDIManager(){ moduleGUIs=new Hashtable(); mainMDIFrame=new MDIFrame(); } - + private void init(){ - if(guiManagerRef.registerMenu("Window")) - { + if(guiManagerRef.registerMenu("Window")) { JMenuItem tmp=new JMenuItem("Cascade"); tmp.setActionCommand("Cascade"); tmp.addActionListener(this); @@ -64,6 +68,7 @@ tmp.addActionListener(this); guiManagerRef.registerMenuItem("Window", tmp, 0.11); + guiManagerRef.registerMenuItem("Developer",createPLAFMenu()); mainMDIFrame.repaint(); } } @@ -78,7 +83,7 @@ guiManagerRef = guiManagerCallbackRef; } - + /** Sets the Menu bar for the Main Frame */ public void setMenuBar(JMenuBar menu) { mainMDIFrame.setJMenuBar(menu); @@ -103,14 +108,12 @@ /*Listens for "Window" Menu events*/ public void actionPerformed(ActionEvent ae) { - if(ae.getActionCommand()=="Cascade") - { + if(ae.getActionCommand()=="Cascade") { mainMDIFrame.cascadeFrames(25); return; } - if(ae.getActionCommand()=="Minimize") - { + if(ae.getActionCommand()=="Minimize") { mainMDIFrame.minimizeFrames(); return; } @@ -118,4 +121,31 @@ JPanel tmp=(JPanel)moduleGUIs.get(ae.getActionCommand()); mainMDIFrame.focusOnModule(tmp); } + + /** + * Generates a Menu that contains the platforms installed look & feels + * and registers action listeners to change the look & feel of the UI. + */ + private JMenuItem createPLAFMenu(){ + JMenu lnf = new JMenu("Change Skin"); + ButtonGroup bg = new ButtonGroup(); + final UIManager.LookAndFeelInfo[] info = UIManager.getInstalledLookAndFeels(); + for (int i = 0; i < info.length; i++){ + JRadioButtonMenuItem item = new JRadioButtonMenuItem(info[i].getName(), i==0); + final String className = info[i].getClassName(); + item.addActionListener(new ActionListener(){ + public void actionPerformed(ActionEvent ae){ + try{ + UIManager.setLookAndFeel(className); + }catch(Exception e){ + log.warning("Exception with Look and Feel "+className+": "+e.getMessage()); + } + SwingUtilities.updateComponentTreeUI(mainMDIFrame); + } + }); + bg.add(item); + lnf.add(item); + } + return lnf; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: NeoSkye <djj...@ya...> - 2006-04-12 20:49:55
|
Sounds like a great addition, I say go for it. Also, if anyone has any problems with the Hide&Show code, or scrolling/sizing issues please let me know. As for the custom layout for SDI mode, other than the dockable interface I really don't have any special layout in mind that would require a custom layout. If you have an idea of one that you would like to see, I am completely open to suggestions or feel free to start on it yourself. I've decided to hold off on the Individual Frame Interface(IDF) until I comment the code I currently have. That shouldn't take long though. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: Snowdog <sn...@ga...> - 2006-04-12 18:41:11
|
I've updated the build files in the SVN so that the netbeans project files are not under version control. You will likely find netbeans unable to load your openrpg2 project directory correctly after this update. You'll have to take steps to restore the project files.... Via Ant (The EASY way): exectute the ant restore-project target in build.xml (Note: all major targets (clean, build, jar, etc.) and the default depend on restore-project and will also result in the restoration of project files) Manually (The not-so-easy way): copy project.template and project.properties.template from the nbproject/templates dir into the nbproject/ dir. Then Rename the copies in nbproject as "project.template" to "project.xml" and "project.properties.template" to "project.properties". --Snowdog |
From: <sno...@us...> - 2006-04-12 18:29:22
|
Revision: 59 Author: snowdog_ Date: 2006-04-12 11:29:09 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=59&view=rev Log Message: ----------- Adding netbeans project files to the ignore list (see revision 58 comment) ViewCVS Links: ------------- http://svn.sourceforge.net/openrpg/?rev=58&view=rev Property Changed: ---------------- trunk/nbproject/ Property changes on: trunk/nbproject ___________________________________________________________________ Name: svn:ignore - private genfiles.properties build-impl.xml + private genfiles.properties build-impl.xml project.properties project.xml This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-12 18:24:47
|
Revision: 58 Author: snowdog_ Date: 2006-04-12 11:20:16 -0700 (Wed, 12 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=58&view=rev Log Message: ----------- Made changes to remove possibility of developers accidentially commiting changes to project files that are based on their local systems. Removed netbeans project files from repository Added template versions for netbeans project files Added automatic restoration of the netbeans project files from the templates to build.xml Moved templated files into dedicated directory under nbproject Modified Paths: -------------- trunk/build.xml Added Paths: ----------- trunk/nbproject/templates/ trunk/nbproject/templates/build-impl.template trunk/nbproject/templates/project.properties.template trunk/nbproject/templates/project.template Removed Paths: ------------- trunk/nbproject/build-impl.template trunk/nbproject/project.properties trunk/nbproject/project.xml Modified: trunk/build.xml =================================================================== --- trunk/build.xml 2006-04-12 06:54:39 UTC (rev 57) +++ trunk/build.xml 2006-04-12 18:20:16 UTC (rev 58) @@ -11,9 +11,15 @@ <available file="build-ext.xml"/> </and> </condition> + + <condition property="project.files.exist"> + <and> + <available file="nbproject/project.xml" /> + <available file="nbproject/project.properties" /> + </and> + </condition> - - <target name="default" depends="load-netbeans-config, check-console-config" /> + <target name="default" depends="restore-project-files, load-netbeans-config, check-console-config" /> <target name="load-netbeans-config" if="netbeans.buildable"> <echo>Building using netbeans build-impl.xml file</echo> <ant antfile="build-ext.xml" target="default" /> @@ -28,7 +34,7 @@ </target> <!-- JAR BUILDING --> - <target name="jar" depends="nb-jar, alt-jar" description="Create project jar files"/> + <target name="jar" depends="restore-project-files, nb-jar, alt-jar" description="Create project jar files"/> <target name="nb-jar" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="jar-separate"/> </target> @@ -37,7 +43,7 @@ </target> <!-- CLEAN --> - <target name="clean" depends="nb-clean, alt-clean" description="Clean up build in dist directories"/> + <target name="clean" depends="restore-project-files, nb-clean, alt-clean" description="Clean up build in dist directories"/> <target name="nb-clean" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="clean"/> </target> @@ -46,7 +52,7 @@ </target> <!-- COMPILE --> - <target name="compile" depends="nb-compile, alt-compile" description="Compile source"/> + <target name="compile" depends="restore-project-files, nb-compile, alt-compile" description="Compile source"/> <target name="nb-compile" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="compile"/> </target> @@ -58,7 +64,7 @@ </target> <!-- DEBUG --> - <target name="debug" depends="nb-debug, alt-debug" description="Debug Project"/> + <target name="debug" depends="restore-project-files, nb-debug, alt-debug" description="Debug Project"/> <target name="nb-debug" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="debug"/> </target> @@ -67,7 +73,7 @@ </target> <!-- JAVADOC --> - <target name="javadoc" depends="nb-javadoc, alt-javadoc" description="Generate Javadoc"/> + <target name="javadoc" depends="restore-project-files, nb-javadoc, alt-javadoc" description="Generate Javadoc"/> <target name="nb-javadoc" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="javadoc"/> </target> @@ -76,7 +82,7 @@ </target> <!-- RUN --> - <target name="run" depends="nb-run, alt-run" description="Run Project"/> + <target name="run" depends="restore-project-files, nb-run, alt-run" description="Run Project"/> <target name="nb-run" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="run"/> </target> @@ -88,7 +94,7 @@ </target> <!-- TEST --> - <target name="test" depends="nb-test, alt-test" description="Run Project"/> + <target name="test" depends="restore-project-files, nb-test, alt-test" description="Run Project"/> <target name="nb-test" if="netbeans.buildable"> <ant antfile="build-ext.xml" inheritRefs="true" target="test"/> </target> @@ -97,20 +103,28 @@ </target> - <target name="start"> + <target name="start" depends="restore-project-files"> <ant antfile="build-alt.xml" target="start"/> </target> <target name="start-client"> <ant antfile="build-alt.xml" target="start-client"/> </target> - <target name="start-server"> + <target name="start-server" depends="restore-project-files"> <ant antfile="build-alt.xml" target="start-server"/> </target> - - <target name="restore" unless="netbeans.buildable" + + <target name="restore" depends="restore-project-files, restore-build-impl"/> + <target name="restore-build-impl" unless="netbeans.buildable" description="Restores build-impl.xml from a template for Netbeans 5.x users"> - <copy file="nbproject/build-impl.template" tofile="nbproject/build-impl.xml"/> + <copy file="nbproject/templates/build-impl.template" tofile="nbproject/build-impl.xml"/> </target> - + <target name="restore-project-files" unless="project.files.exist"> + <antcall target="restore-project"/> + </target> + <target name="restore-project" description="Restores default project setting files from templates"> + <copy file="nbproject/templates/project.template" tofile="nbproject/project.xml"/> + <copy file="nbproject/templates/project.properties.template" tofile="nbproject/project.properties" /> + </target> + </project> Deleted: trunk/nbproject/build-impl.template =================================================================== --- trunk/nbproject/build-impl.template 2006-04-12 06:54:39 UTC (rev 57) +++ trunk/nbproject/build-impl.template 2006-04-12 18:20:16 UTC (rev 58) @@ -1,489 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<!-- -*** GENERATED FROM project.xml - DO NOT EDIT *** -*** EDIT ../build.xml INSTEAD *** - -For the purpose of easier reading the script -is divided into following sections: - - - initialization - - compilation - - jar - - execution - - debugging - - javadoc - - junit compilation - - junit execution - - junit debugging - - applet - - cleanup - ---> -<project xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" name="OpenRPG2-impl" default="default" basedir=".."> - <target name="default" depends="test,jar,javadoc" description="Build and test whole project."/> - <!-- - ====================== - INITIALIZATION SECTION - ====================== - --> - <target name="-pre-init"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-init-private" depends="-pre-init"> - <property file="nbproject/private/private.properties"/> - </target> - <target name="-init-user" depends="-pre-init,-init-private"> - <property file="${user.properties.file}"/> - <!-- The two properties below are usually overridden --> - <!-- by the active platform. Just a fallback. --> - <property value="1.4" name="default.javac.source"/> - <property value="1.4" name="default.javac.target"/> - </target> - <target name="-init-project" depends="-pre-init,-init-private,-init-user"> - <property file="nbproject/project.properties"/> - </target> - <target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property"> - <available property="manifest.available" file="${manifest.file}"/> - <condition property="manifest.available+main.class"> - <and> - <isset property="manifest.available"/> - <isset property="main.class"/> - <not> - <equals trim="true" arg2="" arg1="${main.class}"/> - </not> - </and> - </condition> - <condition property="have.tests"> - <or> - <available file="${test.src.dir}"/> - </or> - </condition> - <condition property="netbeans.home+have.tests"> - <and> - <isset property="netbeans.home"/> - <isset property="have.tests"/> - </and> - </condition> - <condition property="no.javadoc.preview"> - <isfalse value="${javadoc.preview}"/> - </condition> - <property value="" name="run.jvmargs"/> - <property value="" name="javac.compilerargs"/> - <property value="${basedir}" name="work.dir"/> - <condition property="no.deps"> - <and> - <istrue value="${no.dependencies}"/> - </and> - </condition> - </target> - <target name="-post-init"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init"> - <fail unless="src.dir">Must set src.dir</fail> - <fail unless="test.src.dir">Must set test.src.dir</fail> - <fail unless="build.dir">Must set build.dir</fail> - <fail unless="dist.dir">Must set dist.dir</fail> - <fail unless="build.classes.dir">Must set build.classes.dir</fail> - <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> - <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> - <fail unless="build.test.results.dir">Must set build.test.results.dir</fail> - <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> - <fail unless="dist.jar">Must set dist.jar</fail> - </target> - <target name="-init-macrodef-property"> - <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1"> - <attribute name="name"/> - <attribute name="value"/> - <sequential> - <property value="${@{value}}" name="@{name}"/> - </sequential> - </macrodef> - </target> - <target name="-init-macrodef-javac"> - <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/2"> - <attribute name="srcdir" default="${src.dir}"/> - <attribute name="destdir" default="${build.classes.dir}"/> - <attribute name="classpath" default="${javac.classpath}"/> - <attribute name="debug" default="${javac.debug}"/> - <element name="customize" optional="true"/> - <sequential> - <javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> - <classpath> - <path path="@{classpath}"/> - </classpath> - <compilerarg line="${javac.compilerargs}"/> - <customize/> - </javac> - </sequential> - </macrodef> - </target> - <target name="-init-macrodef-junit"> - <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/2"> - <attribute name="includes" default="**/*Test.java"/> - <sequential> - <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed"> - <batchtest todir="${build.test.results.dir}"> - <fileset dir="${test.src.dir}" includes="@{includes}"/> - </batchtest> - <classpath> - <path path="${run.test.classpath}"/> - </classpath> - <syspropertyset> - <propertyref prefix="test-sys-prop."/> - <mapper to="*" from="test-sys-prop.*" type="glob"/> - </syspropertyset> - <formatter usefile="false" type="brief"/> - </junit> - </sequential> - </macrodef> - </target> - <target name="-init-macrodef-nbjpda"> - <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> - <attribute name="name" default="${main.class}"/> - <attribute name="classpath" default="${debug.classpath}"/> - <attribute name="stopclassname" default=""/> - <sequential> - <nbjpdastart stopclassname="@{stopclassname}" name="@{name}" addressproperty="jpda.address" transport="dt_socket"> - <classpath> - <path path="@{classpath}"/> - </classpath> - </nbjpdastart> - </sequential> - </macrodef> - <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1"> - <attribute name="dir" default="${build.classes.dir}"/> - <sequential> - <nbjpdareload> - <fileset dir="@{dir}" includes="${fix.includes}*.class"/> - </nbjpdareload> - </sequential> - </macrodef> - </target> - <target name="-init-macrodef-debug"> - <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/2"> - <attribute name="classname" default="${main.class}"/> - <attribute name="classpath" default="${debug.classpath}"/> - <element name="customize" optional="true"/> - <sequential> - <java classname="@{classname}" fork="true" dir="${work.dir}"> - <jvmarg value="-Xdebug"/> - <jvmarg value="-Xnoagent"/> - <jvmarg value="-Djava.compiler=none"/> - <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/> - <jvmarg line="${run.jvmargs}"/> - <classpath> - <path path="@{classpath}"/> - </classpath> - <syspropertyset> - <propertyref prefix="run-sys-prop."/> - <mapper to="*" from="run-sys-prop.*" type="glob"/> - </syspropertyset> - <customize/> - </java> - </sequential> - </macrodef> - </target> - <target name="-init-macrodef-java"> - <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> - <attribute name="classname" default="${main.class}"/> - <element name="customize" optional="true"/> - <sequential> - <java classname="@{classname}" fork="true" dir="${work.dir}"> - <jvmarg line="${run.jvmargs}"/> - <classpath> - <path path="${run.classpath}"/> - </classpath> - <syspropertyset> - <propertyref prefix="run-sys-prop."/> - <mapper to="*" from="run-sys-prop.*" type="glob"/> - </syspropertyset> - <customize/> - </java> - </sequential> - </macrodef> - </target> - <target name="-init-presetdef-jar"> - <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> - <jar compress="${jar.compress}" jarfile="${dist.jar}"> - <j2seproject1:fileset dir="${build.classes.dir}"/> - </jar> - </presetdef> - </target> - <target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/> - <!-- - =================== - COMPILATION SECTION - =================== - --> - <target name="deps-jar" depends="init" unless="no.deps"/> - <target name="-pre-pre-compile" depends="init,deps-jar"> - <mkdir dir="${build.classes.dir}"/> - </target> - <target name="-pre-compile"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile"> - <j2seproject2:javac/> - <copy todir="${build.classes.dir}"> - <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> - </copy> - </target> - <target name="-post-compile"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/> - <target name="-pre-compile-single"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile"> - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> - <j2seproject2:javac> - <customize> - <patternset includes="${javac.includes}"/> - </customize> - </j2seproject2:javac> - </target> - <target name="-post-compile-single"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/> - <!-- - ==================== - JAR BUILDING SECTION - ==================== - --> - <target name="-pre-pre-jar" depends="init"> - <dirname file="${dist.jar}" property="dist.jar.dir"/> - <mkdir dir="${dist.jar.dir}"/> - </target> - <target name="-pre-jar"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available"> - <j2seproject1:jar/> - </target> - <target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class"> - <j2seproject1:jar manifest="${manifest.file}"/> - </target> - <target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class"> - <j2seproject1:jar manifest="${manifest.file}"> - <j2seproject1:manifest> - <j2seproject1:attribute value="${main.class}" name="Main-Class"/> - </j2seproject1:manifest> - </j2seproject1:jar> - </target> - <target name="-post-jar"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-post-jar" description="Build JAR."/> - <!-- - ================= - EXECUTION SECTION - ================= - --> - <target name="run" depends="init,compile" description="Run a main class."> - <j2seproject1:java> - <customize> - <arg line="${application.args}"/> - </customize> - </j2seproject1:java> - </target> - <target name="run-single" depends="init,compile-single"> - <fail unless="run.class">Must select one file in the IDE or set run.class</fail> - <j2seproject1:java classname="${run.class}"/> - </target> - <!-- - ================= - DEBUGGING SECTION - ================= - --> - <target name="-debug-start-debugger" if="netbeans.home" depends="init"> - <j2seproject1:nbjpdastart name="${debug.class}"/> - </target> - <target name="-debug-start-debuggee" depends="init,compile"> - <j2seproject2:debug> - <customize> - <arg line="${application.args}"/> - </customize> - </j2seproject2:debug> - </target> - <target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/> - <target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init"> - <j2seproject1:nbjpdastart stopclassname="${main.class}"/> - </target> - <target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/> - <target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single"> - <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> - <j2seproject2:debug classname="${debug.class}"/> - </target> - <target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/> - <target name="-pre-debug-fix" depends="init"> - <fail unless="fix.includes">Must set fix.includes</fail> - <property value="${fix.includes}.java" name="javac.includes"/> - </target> - <target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single"> - <j2seproject1:nbjpdareload/> - </target> - <target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/> - <!-- - =============== - JAVADOC SECTION - =============== - --> - <target name="-javadoc-build" depends="init"> - <mkdir dir="${dist.javadoc.dir}"/> - <javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true"> - <classpath> - <path path="${javac.classpath}"/> - </classpath> - <sourcepath> - <pathelement location="${src.dir}"/> - </sourcepath> - <fileset dir="${src.dir}"/> - </javadoc> - </target> - <target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build"> - <nbbrowse file="${dist.javadoc.dir}/index.html"/> - </target> - <target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/> - <!-- - ========================= - JUNIT COMPILATION SECTION - ========================= - --> - <target name="-pre-pre-compile-test" if="have.tests" depends="init,compile"> - <mkdir dir="${build.test.classes.dir}"/> - </target> - <target name="-pre-compile-test"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test"> - <j2seproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/> - <copy todir="${build.test.classes.dir}"> - <fileset dir="${test.src.dir}" excludes="**/*.java"/> - </copy> - </target> - <target name="-post-compile-test"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/> - <target name="-pre-compile-test-single"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single"> - <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> - <j2seproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"> - <customize> - <patternset includes="${javac.includes}"/> - </customize> - </j2seproject2:javac> - </target> - <target name="-post-compile-test-single"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/> - <!-- - ======================= - JUNIT EXECUTION SECTION - ======================= - --> - <target name="-pre-test-run" if="have.tests" depends="init"> - <mkdir dir="${build.test.results.dir}"/> - </target> - <target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run"> - <j2seproject2:junit/> - </target> - <target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run"> - <fail if="tests.failed">Some tests failed; see details above.</fail> - </target> - <target name="test-report" if="have.tests" depends="init"/> - <target name="-test-browse" if="netbeans.home+have.tests" depends="init"/> - <target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/> - <target name="-pre-test-run-single" if="have.tests" depends="init"> - <mkdir dir="${build.test.results.dir}"/> - </target> - <target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single"> - <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> - <j2seproject2:junit includes="${test.includes}"/> - </target> - <target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single"> - <fail if="tests.failed">Some tests failed; see details above.</fail> - </target> - <target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/> - <!-- - ======================= - JUNIT DEBUGGING SECTION - ======================= - --> - <target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test"> - <fail unless="test.class">Must select one file in the IDE or set test.class</fail> - <j2seproject2:debug classpath="${debug.test.classpath}" classname="junit.textui.TestRunner"> - <customize> - <arg line="${test.class}"/> - </customize> - </j2seproject2:debug> - </target> - <target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test"> - <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/> - </target> - <target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/> - <target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single"> - <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/> - </target> - <target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/> - <!-- - ========================= - APPLET EXECUTION SECTION - ========================= - --> - <target name="run-applet" depends="init,compile-single"> - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> - <j2seproject1:java classname="sun.applet.AppletViewer"> - <customize> - <arg value="${applet.url}"/> - </customize> - </j2seproject1:java> - </target> - <!-- - ========================= - APPLET DEBUGGING SECTION - ========================= - --> - <target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single"> - <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> - <j2seproject2:debug classname="sun.applet.AppletViewer"> - <customize> - <arg value="${applet.url}"/> - </customize> - </j2seproject2:debug> - </target> - <target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/> - <!-- - =============== - CLEANUP SECTION - =============== - --> - <target name="deps-clean" depends="init" unless="no.deps"/> - <target name="-do-clean" depends="init"> - <delete dir="${build.dir}"/> - <delete dir="${dist.dir}"/> - </target> - <target name="-post-clean"> - <!-- Empty placeholder for easier customization. --> - <!-- You can override this target in the ../build.xml file. --> - </target> - <target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/> -</project> Deleted: trunk/nbproject/project.properties =================================================================== --- trunk/nbproject/project.properties 2006-04-12 06:54:39 UTC (rev 57) +++ trunk/nbproject/project.properties 2006-04-12 18:20:16 UTC (rev 58) @@ -1,54 +0,0 @@ -application.args= -build.classes.dir=${build.dir}/classes -build.classes.excludes=**/*.java,**/*.form -# This directory is removed when the project is cleaned: -build.dir=build -# Only compile against the classpath explicitly listed here: -build.sysclasspath=ignore -build.test.classes.dir=${build.dir}/test/classes -build.test.results.dir=${build.dir}/test/results -debug.classpath=\ - ${run.classpath} -debug.test.classpath=\ - ${run.test.classpath} -# This directory is removed when the project is cleaned: -dist.dir=dist -dist.jar=${dist.dir}/OpenRPG2.jar -dist.javadoc.dir=${dist.dir}/javadoc -jar.compress=false -javac.classpath= -# Space-separated list of extra javac options -javac.compilerargs= -javac.deprecation=false -javac.source=${default.javac.source} -javac.target=${default.javac.target} -javac.test.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir}:\ - ${libs.junit.classpath} -javadoc.additionalparam= -javadoc.author=true -javadoc.encoding= -javadoc.noindex=false -javadoc.nonavbar=false -javadoc.notree=false -javadoc.private=false -javadoc.splitindex=true -javadoc.use=true -javadoc.version=false -javadoc.windowtitle=OpenRPG2 -main.class=openrpg2.Client -manifest.file=manifest.mf -platform.active=default_platform -run.classpath=\ - ${javac.classpath}:\ - ${build.classes.dir} -# Space-separated list of JVM arguments used when running the project -# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value -# or test-sys-prop.name=value to set system properties for unit tests): -run.jvmargs= -run.test.classpath=\ - ${javac.test.classpath}:\ - ${build.test.classes.dir} -src.dir=src -test.src.dir=test Deleted: trunk/nbproject/project.xml =================================================================== --- trunk/nbproject/project.xml 2006-04-12 06:54:39 UTC (rev 57) +++ trunk/nbproject/project.xml 2006-04-12 18:20:16 UTC (rev 58) @@ -1,16 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> -<project xmlns="http://www.netbeans.org/ns/project/1"> - <type>org.netbeans.modules.java.j2seproject</type> - <configuration> - <data xmlns="http://www.netbeans.org/ns/j2se-project/2"> - <name>OpenRPG2</name> - <minimum-ant-version>1.6</minimum-ant-version> - <source-roots> - <root id="src.dir"/> - </source-roots> - <test-roots> - <root id="test.src.dir"/> - </test-roots> - </data> - </configuration> -</project> Added: trunk/nbproject/templates/build-impl.template =================================================================== --- trunk/nbproject/templates/build-impl.template (rev 0) +++ trunk/nbproject/templates/build-impl.template 2006-04-12 18:20:16 UTC (rev 58) @@ -0,0 +1,489 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- +*** GENERATED FROM project.xml - DO NOT EDIT *** +*** EDIT ../build.xml INSTEAD *** + +For the purpose of easier reading the script +is divided into following sections: + + - initialization + - compilation + - jar + - execution + - debugging + - javadoc + - junit compilation + - junit execution + - junit debugging + - applet + - cleanup + +--> +<project xmlns:j2seproject2="http://www.netbeans.org/ns/j2se-project/2" xmlns:j2seproject1="http://www.netbeans.org/ns/j2se-project/1" name="OpenRPG2-impl" default="default" basedir=".."> + <target name="default" depends="test,jar,javadoc" description="Build and test whole project."/> + <!-- + ====================== + INITIALIZATION SECTION + ====================== + --> + <target name="-pre-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-init-private" depends="-pre-init"> + <property file="nbproject/private/private.properties"/> + </target> + <target name="-init-user" depends="-pre-init,-init-private"> + <property file="${user.properties.file}"/> + <!-- The two properties below are usually overridden --> + <!-- by the active platform. Just a fallback. --> + <property value="1.4" name="default.javac.source"/> + <property value="1.4" name="default.javac.target"/> + </target> + <target name="-init-project" depends="-pre-init,-init-private,-init-user"> + <property file="nbproject/project.properties"/> + </target> + <target name="-do-init" depends="-pre-init,-init-private,-init-user,-init-project,-init-macrodef-property"> + <available property="manifest.available" file="${manifest.file}"/> + <condition property="manifest.available+main.class"> + <and> + <isset property="manifest.available"/> + <isset property="main.class"/> + <not> + <equals trim="true" arg2="" arg1="${main.class}"/> + </not> + </and> + </condition> + <condition property="have.tests"> + <or> + <available file="${test.src.dir}"/> + </or> + </condition> + <condition property="netbeans.home+have.tests"> + <and> + <isset property="netbeans.home"/> + <isset property="have.tests"/> + </and> + </condition> + <condition property="no.javadoc.preview"> + <isfalse value="${javadoc.preview}"/> + </condition> + <property value="" name="run.jvmargs"/> + <property value="" name="javac.compilerargs"/> + <property value="${basedir}" name="work.dir"/> + <condition property="no.deps"> + <and> + <istrue value="${no.dependencies}"/> + </and> + </condition> + </target> + <target name="-post-init"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-init-check" depends="-pre-init,-init-private,-init-user,-init-project,-do-init"> + <fail unless="src.dir">Must set src.dir</fail> + <fail unless="test.src.dir">Must set test.src.dir</fail> + <fail unless="build.dir">Must set build.dir</fail> + <fail unless="dist.dir">Must set dist.dir</fail> + <fail unless="build.classes.dir">Must set build.classes.dir</fail> + <fail unless="dist.javadoc.dir">Must set dist.javadoc.dir</fail> + <fail unless="build.test.classes.dir">Must set build.test.classes.dir</fail> + <fail unless="build.test.results.dir">Must set build.test.results.dir</fail> + <fail unless="build.classes.excludes">Must set build.classes.excludes</fail> + <fail unless="dist.jar">Must set dist.jar</fail> + </target> + <target name="-init-macrodef-property"> + <macrodef name="property" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="name"/> + <attribute name="value"/> + <sequential> + <property value="${@{value}}" name="@{name}"/> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-javac"> + <macrodef name="javac" uri="http://www.netbeans.org/ns/j2se-project/2"> + <attribute name="srcdir" default="${src.dir}"/> + <attribute name="destdir" default="${build.classes.dir}"/> + <attribute name="classpath" default="${javac.classpath}"/> + <attribute name="debug" default="${javac.debug}"/> + <element name="customize" optional="true"/> + <sequential> + <javac srcdir="@{srcdir}" destdir="@{destdir}" debug="@{debug}" deprecation="${javac.deprecation}" source="${javac.source}" target="${javac.target}" includeantruntime="false"> + <classpath> + <path path="@{classpath}"/> + </classpath> + <compilerarg line="${javac.compilerargs}"/> + <customize/> + </javac> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-junit"> + <macrodef name="junit" uri="http://www.netbeans.org/ns/j2se-project/2"> + <attribute name="includes" default="**/*Test.java"/> + <sequential> + <junit showoutput="true" fork="true" dir="${basedir}" failureproperty="tests.failed" errorproperty="tests.failed"> + <batchtest todir="${build.test.results.dir}"> + <fileset dir="${test.src.dir}" includes="@{includes}"/> + </batchtest> + <classpath> + <path path="${run.test.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="test-sys-prop."/> + <mapper to="*" from="test-sys-prop.*" type="glob"/> + </syspropertyset> + <formatter usefile="false" type="brief"/> + </junit> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-nbjpda"> + <macrodef name="nbjpdastart" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="name" default="${main.class}"/> + <attribute name="classpath" default="${debug.classpath}"/> + <attribute name="stopclassname" default=""/> + <sequential> + <nbjpdastart stopclassname="@{stopclassname}" name="@{name}" addressproperty="jpda.address" transport="dt_socket"> + <classpath> + <path path="@{classpath}"/> + </classpath> + </nbjpdastart> + </sequential> + </macrodef> + <macrodef name="nbjpdareload" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="dir" default="${build.classes.dir}"/> + <sequential> + <nbjpdareload> + <fileset dir="@{dir}" includes="${fix.includes}*.class"/> + </nbjpdareload> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-debug"> + <macrodef name="debug" uri="http://www.netbeans.org/ns/j2se-project/2"> + <attribute name="classname" default="${main.class}"/> + <attribute name="classpath" default="${debug.classpath}"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" fork="true" dir="${work.dir}"> + <jvmarg value="-Xdebug"/> + <jvmarg value="-Xnoagent"/> + <jvmarg value="-Djava.compiler=none"/> + <jvmarg value="-Xrunjdwp:transport=dt_socket,address=${jpda.address}"/> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="@{classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper to="*" from="run-sys-prop.*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-macrodef-java"> + <macrodef name="java" uri="http://www.netbeans.org/ns/j2se-project/1"> + <attribute name="classname" default="${main.class}"/> + <element name="customize" optional="true"/> + <sequential> + <java classname="@{classname}" fork="true" dir="${work.dir}"> + <jvmarg line="${run.jvmargs}"/> + <classpath> + <path path="${run.classpath}"/> + </classpath> + <syspropertyset> + <propertyref prefix="run-sys-prop."/> + <mapper to="*" from="run-sys-prop.*" type="glob"/> + </syspropertyset> + <customize/> + </java> + </sequential> + </macrodef> + </target> + <target name="-init-presetdef-jar"> + <presetdef name="jar" uri="http://www.netbeans.org/ns/j2se-project/1"> + <jar compress="${jar.compress}" jarfile="${dist.jar}"> + <j2seproject1:fileset dir="${build.classes.dir}"/> + </jar> + </presetdef> + </target> + <target name="init" depends="-pre-init,-init-private,-init-user,-init-project,-do-init,-post-init,-init-check,-init-macrodef-property,-init-macrodef-javac,-init-macrodef-junit,-init-macrodef-nbjpda,-init-macrodef-debug,-init-macrodef-java,-init-presetdef-jar"/> + <!-- + =================== + COMPILATION SECTION + =================== + --> + <target name="deps-jar" depends="init" unless="no.deps"/> + <target name="-pre-pre-compile" depends="init,deps-jar"> + <mkdir dir="${build.classes.dir}"/> + </target> + <target name="-pre-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-do-compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile"> + <j2seproject2:javac/> + <copy todir="${build.classes.dir}"> + <fileset dir="${src.dir}" excludes="${build.classes.excludes}"/> + </copy> + </target> + <target name="-post-compile"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="compile" depends="init,deps-jar,-pre-pre-compile,-pre-compile,-do-compile,-post-compile" description="Compile project."/> + <target name="-pre-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-do-compile-single" depends="init,deps-jar,-pre-pre-compile"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject2:javac> + <customize> + <patternset includes="${javac.includes}"/> + </customize> + </j2seproject2:javac> + </target> + <target name="-post-compile-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="compile-single" depends="init,deps-jar,-pre-pre-compile,-pre-compile-single,-do-compile-single,-post-compile-single"/> + <!-- + ==================== + JAR BUILDING SECTION + ==================== + --> + <target name="-pre-pre-jar" depends="init"> + <dirname file="${dist.jar}" property="dist.jar.dir"/> + <mkdir dir="${dist.jar.dir}"/> + </target> + <target name="-pre-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-do-jar-without-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" unless="manifest.available"> + <j2seproject1:jar/> + </target> + <target name="-do-jar-with-manifest" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available" unless="manifest.available+main.class"> + <j2seproject1:jar manifest="${manifest.file}"/> + </target> + <target name="-do-jar-with-mainclass" depends="init,compile,-pre-pre-jar,-pre-jar" if="manifest.available+main.class"> + <j2seproject1:jar manifest="${manifest.file}"> + <j2seproject1:manifest> + <j2seproject1:attribute value="${main.class}" name="Main-Class"/> + </j2seproject1:manifest> + </j2seproject1:jar> + </target> + <target name="-post-jar"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="jar" depends="init,compile,-pre-jar,-do-jar-with-manifest,-do-jar-without-manifest,-do-jar-with-mainclass,-post-jar" description="Build JAR."/> + <!-- + ================= + EXECUTION SECTION + ================= + --> + <target name="run" depends="init,compile" description="Run a main class."> + <j2seproject1:java> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject1:java> + </target> + <target name="run-single" depends="init,compile-single"> + <fail unless="run.class">Must select one file in the IDE or set run.class</fail> + <j2seproject1:java classname="${run.class}"/> + </target> + <!-- + ================= + DEBUGGING SECTION + ================= + --> + <target name="-debug-start-debugger" if="netbeans.home" depends="init"> + <j2seproject1:nbjpdastart name="${debug.class}"/> + </target> + <target name="-debug-start-debuggee" depends="init,compile"> + <j2seproject2:debug> + <customize> + <arg line="${application.args}"/> + </customize> + </j2seproject2:debug> + </target> + <target name="debug" if="netbeans.home" depends="init,compile,-debug-start-debugger,-debug-start-debuggee" description="Debug project in IDE."/> + <target name="-debug-start-debugger-stepinto" if="netbeans.home" depends="init"> + <j2seproject1:nbjpdastart stopclassname="${main.class}"/> + </target> + <target name="debug-stepinto" if="netbeans.home" depends="init,compile,-debug-start-debugger-stepinto,-debug-start-debuggee"/> + <target name="-debug-start-debuggee-single" if="netbeans.home" depends="init,compile-single"> + <fail unless="debug.class">Must select one file in the IDE or set debug.class</fail> + <j2seproject2:debug classname="${debug.class}"/> + </target> + <target name="debug-single" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-single"/> + <target name="-pre-debug-fix" depends="init"> + <fail unless="fix.includes">Must set fix.includes</fail> + <property value="${fix.includes}.java" name="javac.includes"/> + </target> + <target name="-do-debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,compile-single"> + <j2seproject1:nbjpdareload/> + </target> + <target name="debug-fix" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix"/> + <!-- + =============== + JAVADOC SECTION + =============== + --> + <target name="-javadoc-build" depends="init"> + <mkdir dir="${dist.javadoc.dir}"/> + <javadoc destdir="${dist.javadoc.dir}" source="${javac.source}" notree="${javadoc.notree}" use="${javadoc.use}" nonavbar="${javadoc.nonavbar}" noindex="${javadoc.noindex}" splitindex="${javadoc.splitindex}" author="${javadoc.author}" version="${javadoc.version}" windowtitle="${javadoc.windowtitle}" private="${javadoc.private}" additionalparam="${javadoc.additionalparam}" failonerror="true"> + <classpath> + <path path="${javac.classpath}"/> + </classpath> + <sourcepath> + <pathelement location="${src.dir}"/> + </sourcepath> + <fileset dir="${src.dir}"/> + </javadoc> + </target> + <target name="-javadoc-browse" if="netbeans.home" unless="no.javadoc.preview" depends="init,-javadoc-build"> + <nbbrowse file="${dist.javadoc.dir}/index.html"/> + </target> + <target name="javadoc" depends="init,-javadoc-build,-javadoc-browse" description="Build Javadoc."/> + <!-- + ========================= + JUNIT COMPILATION SECTION + ========================= + --> + <target name="-pre-pre-compile-test" if="have.tests" depends="init,compile"> + <mkdir dir="${build.test.classes.dir}"/> + </target> + <target name="-pre-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-do-compile-test" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test"> + <j2seproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"/> + <copy todir="${build.test.classes.dir}"> + <fileset dir="${test.src.dir}" excludes="**/*.java"/> + </copy> + </target> + <target name="-post-compile-test"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="compile-test" depends="init,compile,-pre-pre-compile-test,-pre-compile-test,-do-compile-test,-post-compile-test"/> + <target name="-pre-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="-do-compile-test-single" if="have.tests" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single"> + <fail unless="javac.includes">Must select some files in the IDE or set javac.includes</fail> + <j2seproject2:javac srcdir="${test.src.dir}" destdir="${build.test.classes.dir}" debug="true" classpath="${javac.test.classpath}"> + <customize> + <patternset includes="${javac.includes}"/> + </customize> + </j2seproject2:javac> + </target> + <target name="-post-compile-test-single"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="compile-test-single" depends="init,compile,-pre-pre-compile-test,-pre-compile-test-single,-do-compile-test-single,-post-compile-test-single"/> + <!-- + ======================= + JUNIT EXECUTION SECTION + ======================= + --> + <target name="-pre-test-run" if="have.tests" depends="init"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target name="-do-test-run" if="have.tests" depends="init,compile-test,-pre-test-run"> + <j2seproject2:junit/> + </target> + <target name="-post-test-run" if="have.tests" depends="init,compile-test,-pre-test-run,-do-test-run"> + <fail if="tests.failed">Some tests failed; see details above.</fail> + </target> + <target name="test-report" if="have.tests" depends="init"/> + <target name="-test-browse" if="netbeans.home+have.tests" depends="init"/> + <target name="test" depends="init,compile-test,-pre-test-run,-do-test-run,test-report,-post-test-run,-test-browse" description="Run unit tests."/> + <target name="-pre-test-run-single" if="have.tests" depends="init"> + <mkdir dir="${build.test.results.dir}"/> + </target> + <target name="-do-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single"> + <fail unless="test.includes">Must select some files in the IDE or set test.includes</fail> + <j2seproject2:junit includes="${test.includes}"/> + </target> + <target name="-post-test-run-single" if="have.tests" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single"> + <fail if="tests.failed">Some tests failed; see details above.</fail> + </target> + <target name="test-single" depends="init,compile-test-single,-pre-test-run-single,-do-test-run-single,-post-test-run-single" description="Run single unit test."/> + <!-- + ======================= + JUNIT DEBUGGING SECTION + ======================= + --> + <target name="-debug-start-debuggee-test" if="have.tests" depends="init,compile-test"> + <fail unless="test.class">Must select one file in the IDE or set test.class</fail> + <j2seproject2:debug classpath="${debug.test.classpath}" classname="junit.textui.TestRunner"> + <customize> + <arg line="${test.class}"/> + </customize> + </j2seproject2:debug> + </target> + <target name="-debug-start-debugger-test" if="netbeans.home+have.tests" depends="init,compile-test"> + <j2seproject1:nbjpdastart classpath="${debug.test.classpath}" name="${test.class}"/> + </target> + <target name="debug-test" depends="init,compile-test,-debug-start-debugger-test,-debug-start-debuggee-test"/> + <target name="-do-debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,compile-test-single"> + <j2seproject1:nbjpdareload dir="${build.test.classes.dir}"/> + </target> + <target name="debug-fix-test" if="netbeans.home" depends="init,-pre-debug-fix,-do-debug-fix-test"/> + <!-- + ========================= + APPLET EXECUTION SECTION + ========================= + --> + <target name="run-applet" depends="init,compile-single"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject1:java classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject1:java> + </target> + <!-- + ========================= + APPLET DEBUGGING SECTION + ========================= + --> + <target name="-debug-start-debuggee-applet" if="netbeans.home" depends="init,compile-single"> + <fail unless="applet.url">Must select one file in the IDE or set applet.url</fail> + <j2seproject2:debug classname="sun.applet.AppletViewer"> + <customize> + <arg value="${applet.url}"/> + </customize> + </j2seproject2:debug> + </target> + <target name="debug-applet" if="netbeans.home" depends="init,compile-single,-debug-start-debugger,-debug-start-debuggee-applet"/> + <!-- + =============== + CLEANUP SECTION + =============== + --> + <target name="deps-clean" depends="init" unless="no.deps"/> + <target name="-do-clean" depends="init"> + <delete dir="${build.dir}"/> + <delete dir="${dist.dir}"/> + </target> + <target name="-post-clean"> + <!-- Empty placeholder for easier customization. --> + <!-- You can override this target in the ../build.xml file. --> + </target> + <target name="clean" depends="init,deps-clean,-do-clean,-post-clean" description="Clean build products."/> +</project> Property changes on: trunk/nbproject/templates/build-impl.template ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/nbproject/templates/project.properties.template =================================================================== --- trunk/nbproject/templates/project.properties.template (rev 0) +++ trunk/nbproject/templates/project.properties.template 2006-04-12 18:20:16 UTC (rev 58) @@ -0,0 +1,54 @@ +application.args= +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/OpenRPG2.jar +dist.javadoc.dir=${dist.dir}/javadoc +jar.compress=false +javac.classpath= +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.source=${default.javac.source} +javac.target=${default.javac.target} +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit.classpath} +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding= +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle=OpenRPG2 +main.class=openrpg2.Client +manifest.file=manifest.mf +platform.active=default_platform +run.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir} +# Space-separated list of JVM arguments used when running the project +# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value +# or test-sys-prop.name=value to set system properties for unit tests): +run.jvmargs= +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +src.dir=src +test.src.dir=test Property changes on: trunk/nbproject/templates/project.properties.template ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/nbproject/templates/project.template =================================================================== --- trunk/nbproject/templates/project.template (rev 0) +++ trunk/nbproject/templates/project.template 2006-04-12 18:20:16 UTC (rev 58) @@ -0,0 +1,16 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://www.netbeans.org/ns/project/1"> + <type>org.netbeans.modules.java.j2seproject</type> + <configuration> + <data xmlns="http://www.netbeans.org/ns/j2se-project/2"> + <name>OpenRPG2</name> + <minimum-ant-version>1.6</minimum-ant-version> + <source-roots> + <root id="src.dir"/> + </source-roots> + <test-roots> + <root id="test.src.dir"/> + </test-roots> + </data> + </configuration> +</p... [truncated message content] |
From: Snowdog <sn...@ga...> - 2006-04-12 07:32:26
|
I was dinking around with the look and feel capabilities of swing tonight and whipped up a quick menu to change the L&F. The changes however were required to occure in MDIManager to which I've added one method and a single call to register the menu in init(). NeoSky, if you have no objection I'll commit my L&F change to the SVN. --Snowdog |
From: <sno...@us...> - 2006-04-12 06:54:42
|
Revision: 57 Author: snowdog_ Date: 2006-04-11 23:54:39 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=57&view=rev Log Message: ----------- Merging in SF Patch #1469027 for NeoSkye Put modules in JScrollPanes so they can scroll if resized. Also packed them when first created to ensure they size correctly. Fixed an issue with cascading frames. Also made it so you can hide frames by clicking close, and bring them back using the "Window" menu. Still having a weird issue with JInternalFrame not drawing it's border correctly when it gains focus through the "Window" menu. Modified Paths: -------------- trunk/src/openrpg2/common/core/gui/mdi/MDIFrame.java trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java Modified: trunk/src/openrpg2/common/core/gui/mdi/MDIFrame.java =================================================================== --- trunk/src/openrpg2/common/core/gui/mdi/MDIFrame.java 2006-04-12 06:47:56 UTC (rev 56) +++ trunk/src/openrpg2/common/core/gui/mdi/MDIFrame.java 2006-04-12 06:54:39 UTC (rev 57) @@ -22,9 +22,12 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; + import javax.swing.JDesktopPane; import javax.swing.JInternalFrame; import javax.swing.JPanel; +import javax.swing.JScrollPane; + import openrpg2.common.core.ORPGConstants; /** @@ -47,10 +50,13 @@ } public void addModule(String modulename, JPanel modulepanel) { - JInternalFrame newframe=new JInternalFrame(modulename, true, false, true, true); - newframe.setSize(modulepanel.getPreferredSize().width+10, modulepanel.getPreferredSize().height+20); - newframe.getContentPane().add(modulepanel); + JInternalFrame newframe=new JInternalFrame(modulename, true, true, true, true); + JScrollPane jsp=new JScrollPane(modulepanel); + newframe.setDefaultCloseOperation(JInternalFrame.HIDE_ON_CLOSE); + //newframe.setSize(modulepanel.getPreferredSize().width+10, modulepanel.getPreferredSize().height+20); + newframe.getContentPane().add(jsp); mainPane.add(newframe); + newframe.pack(); newframe.setVisible(true); } @@ -61,9 +67,11 @@ public void cascadeFrames(int offset) { JInternalFrame frames[]=mainPane.getAllFrames(); + int j; for(int i=0; i<frames.length; i++) { - frames[i].setLocation(i*offset, i*offset); + j=frames.length-i-1; + frames[i].setLocation(j*offset, j*offset); } } @@ -79,8 +87,15 @@ } public void focusOnModule(JPanel module) { - JInternalFrame tmp=(JInternalFrame)(module.getParent().getParent().getParent().getParent()); - tmp.requestFocusInWindow(); + JInternalFrame tmp=(JInternalFrame)(module.getParent().getParent().getParent().getParent().getParent().getParent()); + + if(!tmp.isVisible()) + tmp.setVisible(true); + + if(tmp.isIcon()) + try{tmp.setIcon(false);}catch(Exception e){} + + mainPane.getDesktopManager().activateFrame(tmp); } } Modified: trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java =================================================================== --- trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java 2006-04-12 06:47:56 UTC (rev 56) +++ trunk/src/openrpg2/common/core/gui/mdi/MDIManager.java 2006-04-12 06:54:39 UTC (rev 57) @@ -105,7 +105,7 @@ public void actionPerformed(ActionEvent ae) { if(ae.getActionCommand()=="Cascade") { - mainMDIFrame.cascadeFrames(10); + mainMDIFrame.cascadeFrames(25); return; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-12 06:47:59
|
Revision: 56 Author: snowdog_ Date: 2006-04-11 23:47:56 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=56&view=rev Log Message: ----------- Minor tweak to group module code. Modified Paths: -------------- trunk/src/openrpg2/common/core/group/GroupClientModule.java trunk/src/openrpg2/common/core/group/GroupServerModule.java Modified: trunk/src/openrpg2/common/core/group/GroupClientModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupClientModule.java 2006-04-11 23:12:13 UTC (rev 55) +++ trunk/src/openrpg2/common/core/group/GroupClientModule.java 2006-04-12 06:47:56 UTC (rev 56) @@ -44,7 +44,7 @@ * Creates a new instance of GroupClientModule */ public GroupClientModule(GroupManager grpmgr) { - groupManager = null; + groupManager = grpmgr; } /** Modified: trunk/src/openrpg2/common/core/group/GroupServerModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupServerModule.java 2006-04-11 23:12:13 UTC (rev 55) +++ trunk/src/openrpg2/common/core/group/GroupServerModule.java 2006-04-12 06:47:56 UTC (rev 56) @@ -36,7 +36,7 @@ /** Creates a new instance of GroupServerModule */ public GroupServerModule(GroupManager grpmgr) { - groupManager = null; + groupManager = grpmgr; } /** This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Mark T. <ma...@ly...> - 2006-04-12 04:46:38
|
Snowdog wrote: > NeoSkye wrote: > >> I'm a bit confused about the suggestion for a pack() >> call. When do components get cut off? what components? >> sorry, just really confused there. But I will >> definately work on the hide/show feature. > > OSX shows this effect more dramatically than XP but here > is an image with the 'cut off' areas pointed out with red > arrows. http://rpg.game-edit.org/orpg/screenshot1.jpg > > On OSX the frame cuts off the popup window roughly though > the middle of the text line. I can get you a screenshot of > that tomorrow if you'd like. This is sort of weird... it's like it's trying to use the minimum size for the panel, but it probably should use the preferred size instead. > In case you don't know pack() resizes containers so they > fit the minimum size of its components. Now this much I am certain of, pack() always tries to use the preferred size of components, not the minimums size. |
From: NeoSkye <djj...@ya...> - 2006-04-12 02:44:56
|
Thanks for the picture, that told me exactly what you meant about the clipping issue. Though I took your advice about initially sizing frames with pack() I realized that that is only a temporary solution because the frames are resizable, so unless we repacked or did not allow resizing, we would run into trouble. So I am adding the JPanel into a JScrollPane so that if it's resized smaller than the JPanel would like, we get scrollbars. Thanks for giving me the heads up and letting me handle the change. As for the show/hide, with luck I'll have them in tonight. __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com |
From: <sno...@us...> - 2006-04-11 23:12:35
|
Revision: 55 Author: snowdog_ Date: 2006-04-11 16:12:13 -0700 (Tue, 11 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=55&view=rev Log Message: ----------- Integrated skeletal group modules into core and made minor changes to module loading scheme. Modified Paths: -------------- trunk/src/openrpg2/client/core/ClientModuleLoader.java trunk/src/openrpg2/client/core/ORPGClient.java trunk/src/openrpg2/common/core/ORPGConstants.java trunk/src/openrpg2/common/core/engine/Engine.java trunk/src/openrpg2/common/core/engine/ModuleLoader.java trunk/src/openrpg2/common/core/engine/ModuleManager.java trunk/src/openrpg2/common/core/group/GroupManager.java trunk/src/openrpg2/common/core/network/NetworkClient.java trunk/src/openrpg2/common/core/network/NetworkServer.java trunk/src/openrpg2/server/core/ORPGServer.java Added Paths: ----------- trunk/src/openrpg2/common/core/group/GroupClientModule.java trunk/src/openrpg2/common/core/group/GroupMessageConstants.java trunk/src/openrpg2/common/core/group/GroupServerModule.java trunk/src/openrpg2/common/core/network/NetworkModuleProvider.java Modified: trunk/src/openrpg2/client/core/ClientModuleLoader.java =================================================================== --- trunk/src/openrpg2/client/core/ClientModuleLoader.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/client/core/ClientModuleLoader.java 2006-04-11 23:12:13 UTC (rev 55) @@ -38,7 +38,7 @@ } protected void loadDefaultModule(){ - + //no default client module (discard unknown messages) } /** Modified: trunk/src/openrpg2/client/core/ORPGClient.java =================================================================== --- trunk/src/openrpg2/client/core/ORPGClient.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/client/core/ORPGClient.java 2006-04-11 23:12:13 UTC (rev 55) @@ -68,7 +68,7 @@ /* SPLASH SCREEN UPDATE */splash.setProgress("Initializing Modules", 20); ClientModuleLoader ml = new ClientModuleLoader(); - ml.setNetworkModule(new NetworkClientModule(nc)); + ml.setNetworkModuleProvider(nc); /* SPLASH SCREEN UPDATE */splash.setProgress("Initializing Engine", 40); Modified: trunk/src/openrpg2/common/core/ORPGConstants.java =================================================================== --- trunk/src/openrpg2/common/core/ORPGConstants.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/ORPGConstants.java 2006-04-11 23:12:13 UTC (rev 55) @@ -43,6 +43,7 @@ //ORPGMESSAGE RESERVED TYPES //These are special message type identifiers that are part of the core implementation and are therefore reserved static final public String TYPE_NETWORK = "_NET_"; + static final public String TYPE_GROUP = "_GRP_"; //OPERATION MODE CONSTANTS Modified: trunk/src/openrpg2/common/core/engine/Engine.java =================================================================== --- trunk/src/openrpg2/common/core/engine/Engine.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/engine/Engine.java 2006-04-11 23:12:13 UTC (rev 55) @@ -108,8 +108,9 @@ guiManager = new GUIManager(developerConsole); groupManager = new GroupManager(networkNotifier); moduleManager = new ModuleManager(moduleLoader); - moduleManager.setGUIManager(guiManager); moduleManager.setMode(OperationMode); + moduleManager.registerGUIManager(guiManager); + moduleManager.registerGroupManager(groupManager); moduleManager.registerNetwork(networkRelay); try{ moduleManager.initialize(); Modified: trunk/src/openrpg2/common/core/engine/ModuleLoader.java =================================================================== --- trunk/src/openrpg2/common/core/engine/ModuleLoader.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/engine/ModuleLoader.java 2006-04-11 23:12:13 UTC (rev 55) @@ -21,10 +21,12 @@ package openrpg2.common.core.engine; -import openrpg2.common.module.NetworkedModule; +import java.util.logging.Logger; +import openrpg2.common.core.group.GroupManager; +import openrpg2.common.core.network.NetworkModuleProvider; /** - * + * Base class to handle low level module loading tasks * @author Snowdog */ public abstract class ModuleLoader { @@ -34,37 +36,63 @@ */ public ModuleManager moduleManager = null; /** - * Private reference to special network module + * Reference to a network object that can supply a NetworkModule */ - private NetworkedModule netMod = null; + public NetworkModuleProvider netModuleProvider = null; + /** + * Standard logging object reference. + */ + private Logger log = Logger.getLogger(this.getClass().getName()); + /** Creates a new instance of ModuleLoader */ public ModuleLoader(){ } /** - * This is a special routine to hand the a network interface module to the ModuleManager. - * It is registered from outside the normal channels due to its need for network - * hook references that it cannot obtain via the normal module loading routines. - * @param networkModuleReference reference to this module loader of special network module + * Informs this ModuleLoader of which ModuleManager will be used when registering modules. + * @param managerReference ModuleManager to register modules with */ - public void setNetworkModule(NetworkedModule networkModuleReference){ - netMod = networkModuleReference; + public void setModuleManagerCallback(ModuleManager managerReference){ + if (managerReference != null){ + moduleManager = managerReference; + }else{ + throw new java.lang.RuntimeException("ModuleLoader provided with null ModuleManager reference!"); + } } /** + * Informs this ModuleLoader of the object that will provide the NetworkModule object. + * @param networkProvider A network reference that will supply a NetworkModule + */ + public void setNetworkModuleProvider(NetworkModuleProvider networkProvider){ + if (networkProvider != null){ + netModuleProvider = networkProvider; + } + } + + /** * Protected method called by the ModuleManager during initialization to register the network module - * @param managerReference The ModuleManager to register the Network Module with - * @throws openrpg2.common.core.engine.NoSuchModuleException This exception is thrown if the Network Module has not be set prior to being handled by the ModuleManager. */ - protected void loadNetworkModule(ModuleManager managerReference) throws NoSuchModuleException{ - moduleManager = managerReference; - if (netMod == null ){ - throw new NoSuchModuleException("Network Module not set"); + protected void loadNetworkModule(){ + moduleManager.registerModule(netModuleProvider.getNetworkModule()); + } + + + /** + * Queries the moduleManager to determine which GroupModule to from the GroupManager. + * @param groupManagerReference GroupManager to get group module from. + */ + protected void loadGroupModule(GroupManager groupManagerReference){ + if( moduleManager.isClient()){ + moduleManager.registerModule(groupManagerReference.getGroupClientModule()); } - moduleManager.registerModule(netMod); + if( moduleManager.isServer()){ + moduleManager.registerModule(groupManagerReference.getGroupServerModule()); + } } + /** * Called by the ModuleManager to load all modules * @param managerReference The ModuleManager to register modules with Modified: trunk/src/openrpg2/common/core/engine/ModuleManager.java =================================================================== --- trunk/src/openrpg2/common/core/engine/ModuleManager.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/engine/ModuleManager.java 2006-04-11 23:12:13 UTC (rev 55) @@ -20,11 +20,13 @@ */ package openrpg2.common.core.engine; +import java.util.logging.Logger; import javax.swing.JPanel; import openrpg2.common.core.network.NetworkMessageRelay; import openrpg2.common.module.NetworkedModule; import openrpg2.common.core.ORPGConstants; import openrpg2.common.core.ORPGMessage; +import openrpg2.common.core.group.GroupManager; import openrpg2.common.core.gui.GUIManager; import openrpg2.common.module.BaseModule; @@ -46,6 +48,8 @@ private ModuleRegistry moduleRegistry = new ModuleRegistry(); private ModuleLoader moduleLoader = null; private GUIManager guiManager = null; + private GroupManager groupManager = null; + private Logger log = Logger.getLogger(this.getClass().getName()); /** Creates a new instance of ModuleManager */ @@ -53,10 +57,6 @@ moduleLoader = modLoader; } - public void setGUIManager(GUIManager m){ - guiManager = m; - } - /** * ModuleManager in Client mode? * @return true if the ModuleManager is in Client mode @@ -114,10 +114,27 @@ */ protected void registerModuleLoader(ModuleLoader loader){ moduleLoader = loader; + } + /** + * Registers a GUIManager with the ModuleManager + * @param m Reference to the GUIManager object that will supply JPanel display service. + */ + public void registerGUIManager(GUIManager m){ + guiManager = m; + } /** + * Registers a GroupManager with the Module Manager + * @param m Reference to the GroupManager object that will supply client grouping and role services + */ + public void registerGroupManager(GroupManager m){ + groupManager = m; + } + + + /** * Called to initialize the ModuleManager. Does a sanity check to make sure the * Network hook and module loader are present then initializes the ModuleManager * @throws openrpg2.common.core.engine.NoNetworkHookException Exception thrown if network hook doesn't exist (failed sanity check) @@ -154,7 +171,9 @@ * Initializes the ModuleManger to service client side modules. */ private void init() throws NoSuchModuleException { - moduleLoader.loadNetworkModule(this); + moduleLoader.setModuleManagerCallback(this); + moduleLoader.loadGroupModule(groupManager); + moduleLoader.loadNetworkModule(); moduleLoader.loadModules(this); } Added: trunk/src/openrpg2/common/core/group/GroupClientModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupClientModule.java (rev 0) +++ trunk/src/openrpg2/common/core/group/GroupClientModule.java 2006-04-11 23:12:13 UTC (rev 55) @@ -0,0 +1,116 @@ +/* + * GroupClientModule.java + * + * Author: snowdog + * Created: April 11, 2006, 1:54 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.group; + +import openrpg2.common.core.ORPGConstants; +import openrpg2.common.core.ORPGMessage; +import openrpg2.common.module.ClientLoadable; +import openrpg2.common.module.NetworkedModule; + + +/** + * GroupClientModule is the loadable module that tracks client grouping + * information client side. This module makes requests for group changes + * for the client to the GroupServerModule on the server and recieves + * confirmation and notification of all group changing activities from + * the server. + * + * @author snowdog + */ + +public class GroupClientModule extends NetworkedModule implements ClientLoadable { + private GroupManager groupManager = null; + + /** + * Creates a new instance of GroupClientModule + */ + public GroupClientModule(GroupManager grpmgr) { + groupManager = null; + } + + /** + * doRegistration is called by the ModuleManager when loading this module to + * allow the module to register components and services with the ModuleManager. + */ + protected void doRegistration(){ + modCom.registerMessageType(ORPGConstants.TYPE_GROUP, this); + } + + /** + * processMessage() is called by message routing threads to handle messages for this module. + * It is required by the NetworkedModule base class. + */ + public void processMessage(ORPGMessage msg){ + //NOTE messages of this type ALWAYS come from the server + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_OP)); + switch(operation){ + case(GroupMessageConstants.OP_REFRESH):{ handleRefreshMessage(msg);break; } + case(GroupMessageConstants.OP_GROUP):{ handleGroupMessage(msg);break; } + case(GroupMessageConstants.OP_CLIENT):{ handleClientMessage(msg); break; } + default: {break;} + } + } + /** + * Handle a message from the server that contains complete + * group information (reload GroupManager data). + * Used primarily when a client connects to a running server + * and needs complete group data initially. + */ + private void handleRefreshMessage(ORPGMessage msg){ + //TODO: pull new group information from message and update GroupManager + } + + /** + * Handles a message that deals with changes to the group + * structure. This can include adding or removing groups + * as well as changing group data. + */ + private void handleGroupMessage(ORPGMessage msg){ + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_SUB_OP)); + switch(operation){ + case(GroupMessageConstants.SUB_OP_ADD):{break; } //add a new group + case(GroupMessageConstants.SUB_OP_DROP):{break; } //remove an existing group + case(GroupMessageConstants.SUB_OP_ALTER):{break; } //change group info + case(GroupMessageConstants.SUB_OP_UPDATE):{break; } //refresh/replace group info + default: {break;} + } + } + + /** + * Handles messages that pertain to changes in clients + * within groups. This includes adding/removing clients + * from groups as well as changes to client roles. + */ + private void handleClientMessage(ORPGMessage msg){ + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_SUB_OP)); + switch(operation){ + case(GroupMessageConstants.SUB_OP_ADD):{break; } //add a new client + case(GroupMessageConstants.SUB_OP_DROP):{break; } //remove an existing client (disconnect) + case(GroupMessageConstants.SUB_OP_ALTER):{break; } //change client info + case(GroupMessageConstants.SUB_OP_UPDATE):{break; } //refresh/replace client info + default: {break;} + } + } + + + +} Property changes on: trunk/src/openrpg2/common/core/group/GroupClientModule.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/src/openrpg2/common/core/group/GroupManager.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/group/GroupManager.java 2006-04-11 23:12:13 UTC (rev 55) @@ -272,4 +272,12 @@ } } } + + public GroupClientModule getGroupClientModule(){ + return new GroupClientModule(this); + } + + public GroupServerModule getGroupServerModule(){ + return new GroupServerModule(this); + } } Added: trunk/src/openrpg2/common/core/group/GroupMessageConstants.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupMessageConstants.java (rev 0) +++ trunk/src/openrpg2/common/core/group/GroupMessageConstants.java 2006-04-11 23:12:13 UTC (rev 55) @@ -0,0 +1,47 @@ +/* + * GroupMessageConstants.java + * + * Author: snowdog + * Created: April 11, 2006, 2:20 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.group; + +/** + * + * @author snowdog + */ + +public class GroupMessageConstants { + + public final static String HEADER_OP = "OP"; + public final static int OP_REFRESH = 0; + public final static int OP_GROUP = 1; + public final static int OP_CLIENT = 2; + + public final static String HEADER_SUB_OP = "SUB"; + public final static int SUB_OP_ADD = 1; + public final static int SUB_OP_DROP = 2; + public final static int SUB_OP_ALTER = 3; + public final static int SUB_OP_MOVE = 4; + public final static int SUB_OP_UPDATE = 5; + + /** Creates a new instance of GroupMessageConstants */ + public GroupMessageConstants() { + } + +} Property changes on: trunk/src/openrpg2/common/core/group/GroupMessageConstants.java ___________________________________________________________________ Name: svn:eol-style + native Added: trunk/src/openrpg2/common/core/group/GroupServerModule.java =================================================================== --- trunk/src/openrpg2/common/core/group/GroupServerModule.java (rev 0) +++ trunk/src/openrpg2/common/core/group/GroupServerModule.java 2006-04-11 23:12:13 UTC (rev 55) @@ -0,0 +1,108 @@ +/* + * GroupServerModule.java + * + * Author: snowdog + * Created: April 11, 2006, 2:45 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.group; + +import openrpg2.common.core.ORPGConstants; +import openrpg2.common.core.ORPGMessage; +import openrpg2.common.module.NetworkedModule; +import openrpg2.common.module.ServerLoadable; + +/** + * + * @author snowdog + */ + +public class GroupServerModule extends NetworkedModule implements ServerLoadable{ + private GroupManager groupManager = null; + + /** Creates a new instance of GroupServerModule */ + public GroupServerModule(GroupManager grpmgr) { + groupManager = null; + } + + /** + * doRegistration is called by the ModuleManager when loading this module to + * allow the module to register components and services with the ModuleManager. + */ + protected void doRegistration(){ + modCom.registerMessageType(ORPGConstants.TYPE_GROUP, this); + } + + /** + * processMessage() is called by message routing threads to handle messages for this module. + * It is required by the NetworkedModule base class. + */ + public void processMessage(ORPGMessage msg){ + //NOTE messages of this type ALWAYS come from the server + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_OP)); + switch(operation){ + case(GroupMessageConstants.OP_REFRESH):{ handleRefreshMessage(msg);break; } + case(GroupMessageConstants.OP_GROUP):{ handleGroupMessage(msg);break; } + case(GroupMessageConstants.OP_CLIENT):{ handleClientMessage(msg); break; } + default: {break;} + } + } + /** + * Handle a message from clients that requests complete + * group information (reload GroupManager data). + * Used primarily when a client connects to a running server + * and needs complete group data initially. + */ + private void handleRefreshMessage(ORPGMessage msg){ + //TODO: construct a refresh group message and send back to requesting client. + } + + /** + * Handles a message that deals with changes to the group + * structure. This can include adding or removing groups + * as well as changing group data. + */ + private void handleGroupMessage(ORPGMessage msg){ + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_SUB_OP)); + switch(operation){ + case(GroupMessageConstants.SUB_OP_ADD):{break; } //add a new group + case(GroupMessageConstants.SUB_OP_DROP):{break; } //remove an existing group + case(GroupMessageConstants.SUB_OP_ALTER):{break; } //change group info + case(GroupMessageConstants.SUB_OP_UPDATE):{break; } //refresh/replace group info + default: {break;} + } + } + + /** + * Handles messages that pertain to changes in clients + * within groups. This includes adding/removing clients + * from groups as well as changes to client roles. + */ + private void handleClientMessage(ORPGMessage msg){ + int operation = Integer.parseInt(msg.getHeader(GroupMessageConstants.HEADER_SUB_OP)); + switch(operation){ + case(GroupMessageConstants.SUB_OP_ADD):{break; } //add a new client + case(GroupMessageConstants.SUB_OP_DROP):{break; } //remove an existing client (disconnect) + case(GroupMessageConstants.SUB_OP_ALTER):{break; } //change client info + case(GroupMessageConstants.SUB_OP_UPDATE):{break; } //refresh/replace client info + default: {break;} + } + } + + + +} \ No newline at end of file Property changes on: trunk/src/openrpg2/common/core/group/GroupServerModule.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/src/openrpg2/common/core/network/NetworkClient.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkClient.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/network/NetworkClient.java 2006-04-11 23:12:13 UTC (rev 55) @@ -35,13 +35,14 @@ import java.util.Set; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.ORPGMessageQueue; +import openrpg2.common.module.NetworkedModule; /** * * @author snowdog */ -public class NetworkClient implements NetworkMessageRelay{ +public class NetworkClient implements NetworkMessageRelay, NetworkModuleProvider{ private ORPGMessageQueue inQueue; private ORPGMessageQueue outQueue; @@ -282,42 +283,44 @@ } }; writeThread.start(); - } - //methods to satisfy NetworkMessageRelay interface - public Observable addMessageQueueObserver(Observer o){ + } + //methods to satisfy NetworkMessageRelay interface + public Observable addMessageQueueObserver(Observer o){ inQueue.addObserver(o); return inQueue; //return reference to object for comparison only in case more than one observable is being monitored. } - /** - * Method to allow an ORPGMessage object to be accepted for processing - * @param msg ORPGMessage Object - * @return boolean. True on success, False on failure - */ - - public boolean putORPGMessage(ORPGMessage msg){ - return sendMessage(msg); + /** + * Method to allow an ORPGMessage object to be accepted for processing + * @param msg ORPGMessage Object + * @return boolean. True on success, False on failure + */ + + public boolean putORPGMessage(ORPGMessage msg){ + return sendMessage(msg); + } + /** + * Retrieve first available ORPGMessage object + * @throws openrpg2.common.core.network.NoMessageAvailableException Thrown if no messages are available for retrieval + * @return ORPGMessage object + */ + public ORPGMessage getORPGMessage() throws NoMessageAvailableException{ + ORPGMessage msg = readMessage(); + if (msg == null){ + throw new NoMessageAvailableException(); } - /** - * Retrieve first available ORPGMessage object - * @throws openrpg2.common.core.network.NoMessageAvailableException Thrown if no messages are available for retrieval - * @return ORPGMessage object - */ - public ORPGMessage getORPGMessage() throws NoMessageAvailableException{ - ORPGMessage msg = readMessage(); - if (msg == null){ - throw new NoMessageAvailableException(); - } - return msg; - } - - /** - * Check if ORPGMessage can be retrieved with getORPGMessage() method - * @return True if 1 or more ORPGMessages are ready for retrieval otherwise false. - */ - public boolean hasORPGMessage(){ - return messageAvailable(); - } - - + return msg; + } + /** + * Check if ORPGMessage can be retrieved with getORPGMessage() method + * @return True if 1 or more ORPGMessages are ready for retrieval otherwise false. + */ + public boolean hasORPGMessage(){ + return messageAvailable(); + } + + + public NetworkedModule getNetworkModule(){ + return new NetworkClientModule(this); + } } Added: trunk/src/openrpg2/common/core/network/NetworkModuleProvider.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkModuleProvider.java (rev 0) +++ trunk/src/openrpg2/common/core/network/NetworkModuleProvider.java 2006-04-11 23:12:13 UTC (rev 55) @@ -0,0 +1,34 @@ +/* + * NetworkModuleProvider.java + * + * Author: snowdog + * Created on April 11, 2006, 3:20 PM + * + * ==================================================================== + * Copyright (C) 2005-2006 The OpenRPG Project (www.openrpg.com) + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License on www.gnu.org for more details. + * ==================================================================== + */ + +package openrpg2.common.core.network; + +import openrpg2.common.module.NetworkedModule; + +/** + * + * @author snowdog + */ +public interface NetworkModuleProvider { + + public NetworkedModule getNetworkModule(); + +} Property changes on: trunk/src/openrpg2/common/core/network/NetworkModuleProvider.java ___________________________________________________________________ Name: svn:eol-style + native Modified: trunk/src/openrpg2/common/core/network/NetworkServer.java =================================================================== --- trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/common/core/network/NetworkServer.java 2006-04-11 23:12:13 UTC (rev 55) @@ -38,6 +38,7 @@ import java.util.logging.Logger; import openrpg2.common.core.ORPGMessage; import openrpg2.common.core.ORPGMessageQueue; +import openrpg2.common.module.NetworkedModule; /** @@ -49,7 +50,7 @@ * @author snowdog */ -public class NetworkServer implements NetworkMessageRelay, NetworkConnectionNotifier{ +public class NetworkServer implements NetworkMessageRelay, NetworkConnectionNotifier, NetworkModuleProvider{ private ServerSocketChannel ssc = null; private Selector selector = null; private boolean initDone = false; @@ -375,4 +376,12 @@ } + /** + * Required for implementation of NetworkModuleProvider interface. + * + */ + public NetworkedModule getNetworkModule(){ + return new NetworkServerModule(this); + } + } Modified: trunk/src/openrpg2/server/core/ORPGServer.java =================================================================== --- trunk/src/openrpg2/server/core/ORPGServer.java 2006-04-11 06:37:32 UTC (rev 54) +++ trunk/src/openrpg2/server/core/ORPGServer.java 2006-04-11 23:12:13 UTC (rev 55) @@ -51,7 +51,7 @@ NetworkServer server = new NetworkServer(); ServerModuleLoader ml = new ServerModuleLoader(); - ml.setNetworkModule(new NetworkServerModule(server)); + ml.setNetworkModuleProvider(server); Engine thor = new Engine(server, server, ml, d, ORPGConstants.OPMODE_SERVER); thor.start(); server.setServerAddress(new InetSocketAddress(NetworkConnection.DEFAULT_HOST, NetworkConnection.DEFAULT_PORT)); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <sno...@us...> - 2006-04-11 06:37:40
|
Revision: 54 Author: snowdog_ Date: 2006-04-10 23:37:32 -0700 (Mon, 10 Apr 2006) ViewCVS: http://svn.sourceforge.net/openrpg/?rev=54&view=rev Log Message: ----------- updating splashimage.png to a more acceptable image. Modified Paths: -------------- trunk/src/openrpg2/common/resources/core/splashimage.png Modified: trunk/src/openrpg2/common/resources/core/splashimage.png =================================================================== (Binary files differ) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: Snowdog <sn...@ga...> - 2006-04-11 05:39:12
|
NeoSkye wrote: > I'm a bit confused about the suggestion for a pack() > call. When do components get cut off? what components? > sorry, just really confused there. But I will > definately work on the hide/show feature. OSX shows this effect more dramatically than XP but here is an image with the 'cut off' areas pointed out with red arrows. http://rpg.game-edit.org/orpg/screenshot1.jpg On OSX the frame cuts off the popup window roughly though the middle of the text line. I can get you a screenshot of that tomorrow if you'd like. In case you don't know pack() resizes containers so they fit the minimum size of its components. See the difference for yourself... Add "newframe.pack();" at line 53 in MDIFrame (as of SVN revision 53) as shown below.... public void addModule(String modulename, JPanel modulepanel) { JInternalFrame newframe=new JInternalFrame( modulename, true, false, true, true); newframe.setSize(modulepanel.getPreferredSize().width+10, modulepanel.getPreferredSize().height+20); newframe.getContentPane().add(modulepanel); > newframe.pack(); mainPane.add(newframe); newframe.setVisible(true); } This is one of those things I'd usually commit without delegation but, being as you asked I figured I'd oblige. |
From: Mark T. <ma...@ly...> - 2006-04-11 05:13:37
|
NeoSkye wrote: > I haven't figured out yet how to manage the JPanels in > an SDI environment. That's mostly the reason I haven't > worked on it yet. My dream layout I think would be > something of a dockable interface where the user could > drag a JPanel to the general location of where they > want it. If you know how the SDI would be best > accomplished though, feel free to write it. > > I'm a bit confused about the suggestion for a pack() > call. When do components get cut off? what components? > sorry, just really confused there. But I will > definately work on the hide/show feature. I take it then that you have never designed a LayoutManager before? They are actually very easy to design, and even kind of fun... once you get the hang of it. Netbeans includes the source code to one... AbsoluteLayoutManager... I recommend loojubg at it for getting the basic idea of how to create your own. (Just don't use the same serialize id). You can also find a few other sample layout here: http://www.leepoint.net/notes-java/GUI/layouts/90independent-managers.html Creating dockable components is an entire project in and of itself. Doable, but quite complex. >> Mark |