1 /* 2 * Replica is published under the terms 3 * of the Apache Software License. 4 */ 5 package replica.database.commands; 6 7 import replica.core.ApplicationCommand; 8 import replica.core.ApplicationMessage; 9 import replica.server.commands.PrintCommand; 10 import replica.session.Session; 11 12 /*** 13 * This command is used to replicate the session into the several group members. 14 * 15 * The server connect command, creates the new session and then sends a connect 16 * command message to the group. This command then simplely, creates a new session 17 * in each memeber with the same sessionId. 18 * 19 * The session will be required to store the user state in all the members. The connection must 20 * stored on the user session and cannot be closed, until the user commits. 21 * 22 * @author Pedro Costa 23 * @author Helder Silva 24 * @since 20/Jan/2004 25 */ 26 public class ConnectCommand extends ApplicationCommand { 27 28 /*** 29 * 30 */ 31 public ConnectCommand() { 32 super(); 33 } 34 35 /* (non-Javadoc) 36 * @see replica.server.commands.ServerCommand#execute(replica.server.ServerCommandVO) 37 */ 38 public Object execute(ApplicationMessage arg) { 39 40 if( getSessionManager().getSession(arg.getSessionID()) != null ) 41 return null; 42 43 getSessionManager().createSession(arg.getSessionID(), 44 (String)arg.getHeader("USER"), (String)arg.getHeader("PASSWORD")); 45 46 Session session = getSessionManager().getSession(arg.getSessionID()); 47 48 String database = (String)arg.getHeader("DATABASE_NAME"); 49 50 if( database != null ) 51 session.putObject("DATABASE_NAME", database); 52 53 return PrintCommand.NAME + " Connected."; 54 } 55 56 }

This page was automatically generated by Maven