use of org.compiere.interfaces.Status in project adempiere by adempiere.
the class StatusInfo method doGet.
/**
* Get
* @param request
* @param response
* @throws ServletException
* @throws IOException
*/
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<head><title>Status Info</title></head>");
out.println("<body>");
InitialContext context = null;
try {
context = new InitialContext();
} catch (Exception ex) {
out.println("<p><b>" + ex + "</b></p>");
}
try {
Status status = (Status) context.lookup(Status.JNDI_NAME);
out.println("<p>" + status.getStatus() + "</p>");
} catch (Exception ex) {
out.println("<p><b>" + ex + "</b></p>");
}
try {
Server server = (Server) context.lookup(Server.JNDI_NAME);
out.println("<p>" + server.getStatus() + "</p>");
} catch (Exception ex) {
out.println("<p><b>" + ex + "</b></p>");
}
try {
out.println("<h2>-- /</h2>");
NamingEnumeration ne = context.list("/");
while (ne.hasMore()) out.println("<br> " + ne.nextElement());
out.println("<h2>-- java</h2>");
ne = context.list("java:");
while (ne.hasMore()) out.println("<br> " + ne.nextElement());
out.println("<h2>-- ejb</h2>");
ne = context.list("ejb");
while (ne.hasMore()) out.println("<br> " + ne.nextElement());
//
out.println("<h2>-- DS</h2>");
DataSource ds = (DataSource) context.lookup("java:/OracleDS");
out.println("<br> DataSource " + ds.getClass().getName() + " LoginTimeout=" + ds.getLoginTimeout());
Connection con = ds.getConnection("adempiere", "adempiere");
out.println("<br> Connection ");
getServletContext().log("Connection closed=" + con.isClosed());
DatabaseMetaData dbmd = con.getMetaData();
getServletContext().log("DB " + dbmd.getDatabaseProductName());
getServletContext().log("DB V " + dbmd.getDatabaseProductVersion());
getServletContext().log("Driver " + dbmd.getDriverName());
getServletContext().log("Driver V " + dbmd.getDriverVersion());
getServletContext().log("JDBC " + dbmd.getJDBCMajorVersion());
getServletContext().log("JDBC mV " + dbmd.getJDBCMinorVersion());
getServletContext().log("User " + dbmd.getUserName());
getServletContext().log("ANSI 92 " + dbmd.supportsANSI92FullSQL());
getServletContext().log("Connection Alter Table ADD" + dbmd.supportsAlterTableWithAddColumn());
getServletContext().log("Connection Alter Table DROP " + dbmd.supportsAlterTableWithDropColumn());
getServletContext().log("Connection DDL&DML " + dbmd.supportsDataDefinitionAndDataManipulationTransactions());
getServletContext().log("Connection CatalogsIn DML " + dbmd.supportsCatalogsInDataManipulation());
getServletContext().log("Connection Schema In DML " + dbmd.supportsSchemasInDataManipulation());
con.close();
} catch (Exception e) {
out.println("<p><b>" + e + "</b></p>");
}
out.println("</body></html>");
}
use of org.compiere.interfaces.Status in project adempiere by adempiere.
the class CConnection method isAppsServerOK.
// setAppsPort
/**
* Is Application Server OK
* @param tryContactAgain try to contact again
* @return true if Apps Server exists
*/
public boolean isAppsServerOK(boolean tryContactAgain) {
if (isServerEmbedded())
return true;
if (Ini.isClient() && !tryContactAgain && m_queryAppsServer)
return m_okApps;
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
log.warning(getAppsHost() + " ignored");
return false;
}
m_queryAppsServer = true;
// Contact it
try {
Status status = (Status) lookup(Status.JNDI_NAME);
m_version = status.getDateVersion();
m_okApps = true;
} catch (Exception ce) {
m_okApps = false;
String connect = (String) m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning(connect + "\n - " + ce.toString() + "\n - " + m_env);
ce.printStackTrace();
} catch (Throwable t) {
m_okApps = false;
String connect = (String) m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning(connect + "\n - " + t.toString() + "\n - " + m_env);
t.printStackTrace();
}
return m_okApps;
}
use of org.compiere.interfaces.Status in project adempiere by adempiere.
the class CConnection method queryAppsServerInfo.
// getInitialEnvironment
/**
* Query Application Server Status.
* update okApps
* @return true ik OK
*/
private boolean queryAppsServerInfo() {
log.finer(getAppsHost());
long start = System.currentTimeMillis();
m_okApps = false;
m_queryAppsServer = true;
m_appsException = null;
// Carlos Ruiz - globalqss - speed up when jnp://MyAppsServer:1099 is set
if (getAppsHost().equalsIgnoreCase("MyAppsServer")) {
log.warning(getAppsHost() + " ignored");
// false
return m_okApps;
}
try {
Status status = (Status) lookup(Status.JNDI_NAME);
//
updateInfoFromServer(status);
//
m_okApps = true;
} catch (// not a "real" error
CommunicationException ce) {
m_appsException = ce;
String connect = (String) m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning(connect + "\n - " + ce.toString() + "\n - " + m_env);
ce.printStackTrace();
} catch (Exception e) {
m_appsException = e;
String connect = (String) m_env.get(Context.PROVIDER_URL);
if (connect == null || connect.trim().length() == 0)
connect = getAppsHost() + ":" + getAppsPort();
log.warning(connect + "\n - " + e.toString() + "\n - " + m_env);
e.printStackTrace();
}
log.fine("Success=" + m_okApps + " - " + (System.currentTimeMillis() - start) + "ms");
return m_okApps;
}
use of org.compiere.interfaces.Status in project adempiere by adempiere.
the class ConnectTest method testEJB.
// testJNP
/**
* Test EJB
* @param serverName server name
* @param context context
*/
private void testEJB(String serverName, InitialContext context) {
System.out.println();
System.out.println("Connecting to EJB server ...");
try {
System.out.println(" Name=" + Status.JNDI_NAME);
Status sta = (Status) context.lookup(Status.JNDI_NAME);
System.out.println(" .. bean created");
System.out.println(" ServerVersion=" + sta.getMainVersion() + " " + sta.getDateVersion());
System.out.println(" .. bean removed");
} catch (Exception e) {
System.err.println("ERROR: Could not connect: " + e);
return;
}
System.out.println();
System.out.println("SUCCESS !!");
}
Aggregations