BLOG ARTICLE JBoss WAS | 3 ARTICLE FOUND

  1. 2009/01/19 JBoss - Oracle T4 Connection 얻어오기
  2. 2009/01/19 JSP를 이용한 vm memory 확인
  3. 2008/10/29 JBoss Embed Operation 1.0

import java.sql.Connection;
import javax.naming.InitialContext;
import javax.sql.DataSource;

public class OracleConnectionUtil
{
 public static Connection getOracleConnection(String jndi)
  try{
   InitialContext ctx = new InitialContext();
   DataSource datasource = (DataSource) ctx.lookup(jndi);
   Connection connection = datasource.getConnection();
   //cast this to JBoss specific WrappedConnection
   org.jboss.resource.adapter.jdbc.WrappedConnection wrappedConnection =  (org.jboss.resource.adapter.jdbc.WrappedConnection) connection;
   //get the underlying connection (T4CConnection)
   Connection underlyingConnection = wrappedConnection.getUnderlyingConnection();

   //cast to T4CConnection if some specific API on this object is to be used
   oracle.jdbc.OracleConnection t4cConnection = (oracle.jdbc.OracleConnection) underlyingConnection;
   out.println("Oracle Connection : " + t4cConnection);
   return t4cConnection;
  }catch(Exception e) {
   System.out.println("Exception while getting oracle connection :::: " + e.getMessage());
  }
  return null;
 }

 public static void close(Connection conn) {
  try{
   if( conn != null ) conn.close();
  }catch(Exception e) {
   // Ignore when the connection closing
  }
 }
}

// 오라클에서 얻어온 connection을 close할 경우 casting된 connection은 실제 connection이므로
// close시 실제 연결이 끊어지게 되는 현상이 발생합니다.

// 아래의 같이 DataSource의 proxy connection을 close해야만 WAS의 connection pool로 반환하게 됩니다.  

   Connection conn = DataSource.getConnection();
   Connection oracleConn = conn.getUnderlyingConnection();
  
   //Do JDBC stuff heere

   //CLOSE THE HANDLE, NOT THE UNDERLYING CONNECTION!!!!
   conn.close();
 
   conn = DataSource.getConnection();
   oracleConn = conn.getUnderlyingConnection();


 

크리에이티브 커먼즈 라이센스
Creative Commons License
2009/01/19 10:00 2009/01/19 10:00

아래의 코드를 복사하셔서 web application context에 vm.jsp로 저장하신 후 확인하시면 됩니다.

<%@ page contentType="text/html; charset=euc-kr" %>
<%@ page import="java.net.InetAddress" %>
<%@ page import="java.text.*" %>
<%@ page import="java.util.*" %>

<%
  if (request.getParameter("gc") != null) {
    System.gc();
    System.runFinalization();
  }
 Properties p = System.getProperties();
%>

<HTML>
<HEAD>
<META content="text/html; charset=euc-kr" http-equiv=Content-Type>
<!--META http-equiv="Refresh" content="10;url=<%= request.getRequestURI() %>"-->
<link href="style.css" rel=stylesheet type="text/css">
</HEAD>

<body leftmargin=15 topmargin=10>
<center><p>

<table width="600" cellpadding="7" cellspacing="0" border="1" bordercolordark="WHITE" bordercolorlight="BLACK">
<tr><td>
■ HOST : <%= InetAddress.getLocalHost().getHostName() %>
(<%= InetAddress.getLocalHost().getHostAddress() %>)&nbsp;&nbsp;
<% SimpleDateFormat formatter = new SimpleDateFormat("yyyy.MM.dd 'at' HH:mm:ss z", Locale.CHINA); %>
■ Current Time : <%= formatter.format(new Date()) %>
</td></tr>

<tr><td align=center>

<%
   Runtime rt = Runtime.getRuntime();
   long free = rt.freeMemory();
   long total = rt.totalMemory();
   long usedRatio = (total - free) * 100 / total;
   long unusedRatio = free * 100 / total;
%>

<table width=100% bgcolor="lightgrey" border=1 cellpadding=6 cellspacing=0>
<tr>
<td align="center" colspan="2">Total Java Virual Machine Memory (<b><%= total/1024 %> KB</b>)</td>
</tr>
<tr bgcolor=#E3E3E3>
<td align="center">Used Memory (<b><%= (total - free)/1024 %> KB</b>)</td>
<td align="center">Available Memory (<b><%= free/1024 %> KB</b>)</td>
</tr>
<tr bgcolor=#E8EEEC>
<td><hr color="#CC3366" align=left size=10 width="<%= usedRatio %>%" noshade>
(<%= usedRatio %> %)</td>
<td><hr color="#0066FF" align=left size=10 width="<%= unusedRatio %>%" noshade>
(<%= unusedRatio %> %)</td>
</tr>
</table>

<p>
<a href="<%= request.getRequestURI() %>?gc=">
<img src="trash.gif" valign=middle border=0>&nbsp;Execution GC</a>
&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;
<a href="<%= request.getRequestURI() %>">
<img src="refresh.gif" valign=middle border=0>&nbsp;Reload</a>

</td></tr>
</table>

</center>
</BODY>
</HTML>

크리에이티브 커먼즈 라이센스
Creative Commons License
2009/01/19 09:58 2009/01/19 09:58

JBoss의 특징은 한 마디로 요약하면 developer oriented web application server라는 점입니다. 다시 말하면 다양한 xml configuration을 이용하여 설정을 최대한 유용하게 한다는 것인데 이게 또한 장점이면서 단점입니다.

JMX Consolidation을 이용하여 모든 작업을 web console에서 작업하도록 해야 사용자들이 xml설정에 대한 실수을 줄일 수 있을 뿐더러 보다 쉽게 접근할 수 있을텐데요.

그러한 프로젝트의 일환으로 community에서는 jopr이라는 프로젝트를 진행하고 있습니다. WebLogic 8 version의 admin console같은 형태로 구성되어 있습니다.

http://www.jboss.org/embjopr/

간단한 데모는 다음과 같습니다.

http://www.jboss.org/file-access/default/members/embjopr/freezone/demo/embjopr-demo.swf
크리에이티브 커먼즈 라이센스
Creative Commons License
2008/10/29 14:52 2008/10/29 14:52