Also es ist so, dass ich bisher eine klasse hatte aus der ich auf die methoden einer anderen zugegriffen habe.. jetz will / muss ich eine neue klasse erstellen, die sozusagen eine weiterleitung ist...
ich soll auf diese neue "weiterleitungsklasse" zugreifen und in dieser stehen dann die weiterleitungen zu der dritten.
aber es will irgendwie nicht..
kann mir einer sagen was an dem code nicht stimmt?
ist der konstruktor denn überhaupt wichtig? denn das "conprov" in zeile 30 ist in eclipse gelb unterlegt sprich es wird nicht abgerufen... obwohl ichs doch bei login schon abrufe?! oder nich?
hoffe es ist klar was ich meine
ich soll auf diese neue "weiterleitungsklasse" zugreifen und in dieser stehen dann die weiterleitungen zu der dritten.
aber es will irgendwie nicht..
kann mir einer sagen was an dem code nicht stimmt?
ist der konstruktor denn überhaupt wichtig? denn das "conprov" in zeile 30 ist in eclipse gelb unterlegt sprich es wird nicht abgerufen... obwohl ichs doch bei login schon abrufe?! oder nich?
Code:
package connection;
import javax.sql.ConnectionEvent;
import javax.swing.JOptionPane;
import connection.ConnectionEventTypes;
/**
* Implementation of ConnectionController and ConnectionListener.
*
*
* @author Dima
*
*/
public class ConnectionControllerImplementation implements
ConnectionController, ConnectionListener {
/**
* Der Konstruktor für die Connection Klasse.
*
* @param docon
*/
private ConnectionProvider conprov;
public ConnectionControllerImplementation(ConnectionProvider docon) {
final ConnectionProvider conprov = docon;
}
public boolean login(String username, String password) {
if (conprov.login(username, password)) {
return true;
} else {
return false;
}
}
public boolean logout() {
if (conprov.logout()) {
return true;
} else {
return false;
}
}
public boolean register(String username, String password) {
if (conprov.register(username, password)) {
return true;
} else {
return false;
}
}
public void setConnectionProvider(ConnectionProvider provider) {
// TODO Auto-generated method stub
}
public void processConnectionEvent(ConnectionEvent event) {
if (event.equals(ConnectionEventTypes.LOGIN_OK)) {
JOptionPane.showMessageDialog(null, "Login successful.", "Info!",
JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.LOGIN_FAILED)) {
JOptionPane.showMessageDialog(null, "Login not successful.",
"Info!", JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.REGISTER_OK)) {
JOptionPane.showMessageDialog(null, "Registration successful.",
"Info!", JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.REGISTER_FAILED)) {
JOptionPane.showMessageDialog(null, "Registration not successful.",
"Info!", JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.NEW_CONNECTION)) {
JOptionPane.showMessageDialog(null,
"Successfully connected to Server.", "Info!",
JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.LOST_CONNECTION)) {
JOptionPane.showMessageDialog(null, "Lost Connection to Server.",
"Info!", JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.LOGOUT_OK)) {
JOptionPane.showMessageDialog(null, "Successfully logged out.",
"Info!", JOptionPane.INFORMATION_MESSAGE);
}
if (event.equals(ConnectionEventTypes.LOGOUT_FAILED)) {
JOptionPane.showMessageDialog(null, "Could not log out.", "Info!",
JOptionPane.INFORMATION_MESSAGE);
}
}
public boolean connect(String server) {
String serverurl = server;
if (conprov.connect(serverurl)){
return true;
}
else return false;
}
}
hoffe es ist klar was ich meine