config.setSecurityEnabled(true);
config.setSecurityPolicyFile("C:/flux-7-3-1/fluxjaas.policy");
config.setSecurityConfigurationFile("C:/flux-7-3-1/fluxjaas.config");
Make sure the file directories above reflect your installation directory of Flux.RemoteSecurity rs = fluxFactory.makeRemoteSecurity(config, e);
server = rs.login("user","password");
*Set up WebSphere Configuration*import flux.*;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.rmi.RemoteException;
import java.io.IOException;
public class EngineAsRMIOne extends HttpServlet {
Factory fluxFactory = null;
static Engine server = null;
public EngineAsRMIOne() {
} // constructor
public void service(HttpServletRequest req, HttpServletResponse res) throws IOException {
System.out.println("In the service method");
} // service()
private void createServer() throws EngineException, RemoteException {
if (server == null) {
fluxFactory = Factory.makeInstance();
Configuration config = fluxFactory.makeConfiguration();
config.setRegistryPort(1099);
config.setDatabaseType(DatabaseType.MYSQL);
config.setDriver("com.mysql.jdbc.Driver");
config.setUrl("jdbc:mysql://localhost:3306/flux");
config.setJdbcUsername("root");
config.setJdbcPassword("admin");
config.setTablePrefix("FLUX_");
config.setMaxConnections(5);
config.setSecurityEnabled(true);
config.setSecurityPolicyFile("C:/flux-7-3-1/fluxjaas.policy");
config.setSecurityConfigurationFile("C:/flux-7-3-1/fluxjaas.config");
try {
Engine e = fluxFactory.makeEngine(config);
RemoteSecurity rs = fluxFactory.makeRemoteSecurity(config, e);
server = rs.login("admin","admin");
server.start();
}
catch(Exception ee) {
System.out.println("error when initializing engine");
ee.printStackTrace();
}
}
} // createServer()
public void init() throws ServletException {
System.out.println("In the init.Flux");
super.init();
System.out.println("called my super Flux");
try {
createServer();
System.out.println("called create Flux");
new ServerThread().start();
System.out.println("created new server thread Flux");
}catch (RemoteException e) {
throw new ServletException(e);
}
catch (Exception e) {
System.out.println("Flux Engine Exception Flux");
e.printStackTrace();
}
System.out.println("server Flux" + server);
} // init()
public void destroy() {
if (server != null) {
try {
server.dispose();
} catch (RemoteException e) {
e.printStackTrace();
}
catch (EngineException fluxE) {
// ignore
}
}
if (server != null) {
try {
for (int i = 0; !server.isDisposed() && i < 10; i++) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
// ignore
}
}
} catch (EngineException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
}
super.destroy();
} // destroy()
public static class ServerThread extends Thread {
public void run() {
System.out.println("In the run Flux");
try {
while (!server.isDisposed()) {
try {
Thread.sleep(1000);
System.out.println("Flux is sleeping");
if (server != null) {
if (server.isDisposed()) {
break;
}
}
} catch (InterruptedException e) {
// ignore
}
}
System.out.println("I'm outside of run's while loop Flux");
} catch (EngineException e) {
e.printStackTrace();
} catch (RemoteException e) {
e.printStackTrace();
}
} // run()
} // ServerThread
}
There are no comments on this document