|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
ConnectCommand.java | 0% | 0% | 0% | 0% |
|
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 | 0 |
public ConnectCommand() {
|
32 | 0 |
super();
|
33 |
} |
|
34 |
|
|
35 |
/* (non-Javadoc)
|
|
36 |
* @see replica.server.commands.ServerCommand#execute(replica.server.ServerCommandVO)
|
|
37 |
*/
|
|
38 | 0 |
public Object execute(ApplicationMessage arg) {
|
39 |
|
|
40 | 0 |
if( getSessionManager().getSession(arg.getSessionID()) != null ) |
41 | 0 |
return null; |
42 |
|
|
43 | 0 |
getSessionManager().createSession(arg.getSessionID(), |
44 |
(String)arg.getHeader("USER"), (String)arg.getHeader("PASSWORD")); |
|
45 |
|
|
46 | 0 |
Session session = getSessionManager().getSession(arg.getSessionID()); |
47 |
|
|
48 | 0 |
String database = (String)arg.getHeader("DATABASE_NAME");
|
49 |
|
|
50 | 0 |
if( database != null ) |
51 | 0 |
session.putObject("DATABASE_NAME", database);
|
52 |
|
|
53 | 0 |
return PrintCommand.NAME + " Connected."; |
54 |
} |
|
55 |
|
|
56 |
} |
|
57 |
|
|