100 likes | 242 Vues
This technical exploration by Michael Chaney, Technical Director at ChainLink Networking Solutions, highlights the advantages and challenges of leveraging Object-Oriented (OO) features within the Java framework of WebSphere. It discusses benefits such as code reusability, simplified application design, and reduced ownership costs, while also addressing disadvantages like the need for higher initial expertise and upfront development effort. Practical examples include storing complex data types and implementing user-defined functions in SQL, demonstrating the power and flexibility of OO design.
E N D
Leveraging OO Features of IDS within the Java OO Framework of WebSphere Michael Chaney Technical Director ChainLink Networking Solutions, Inc.
Object Oriented Design • Advantages • Code re-use • Simplified application design • Lower cost of ownership • Disadvantages • Initial development requires higher expertise • More upfront development effort required
IDS Advantages • Storage of arbitrarily complex data • Inheritance (OO) • Polymorphism (OO) • User defined types • User defined functions • C, Java, SQL • Functional indexes
Web Object Example • All web content stored in single table create table web_content ( id integer primary key, object web_object_t ); • Objects stored within user defined web_object_t base type
SQL Example • Functional index create index i_web_content_type on web_content ( content_type(object) ); • Convert PDF document to HTML select object::html_t from web_content where content_type(object)='application/pdf';
Java Object Access ... java.util.Map map = conn.getTypeMap(); map.put(“web_object_t", Class.forName(“WebObject")); … map.put("pdf_t", Class.forName("PdfObject")); conn.setTypeMap(map); ... ResultSet rs=statement.executeQuery("select * from web_content ;”); while (rs.next()){ WebObject wbObj=(WebObject)rs.getObject(“object”); out.write(wbObj.embed()); // embed into HTML page }
Java Object Implementation public class WebObject implements SQLData { private String sql_type=“web_object_t”; String getSQLTypeName() { return sql_type; } void readSQL(SQLInput stream, String typeName) { ... } void writeSQL(SQLOutput stream) { ... } ... /// implementation details ... public String getContentType() { … } // object mime type public String embed() { … } // embedded display within HTML public InputStream getData() { … } // Get native object date bytes }
WebSphere Native Object Display public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // ... ServletOutputStream out= response.getOutputStream(); ResultSet rs=stmt.executeQuery( "select object from web_content where id=" + request.getParameter("id") ); if (rs.next()){ WebObject wbObj=(WebObject)rs.getObject("object"); response.setContentType( wbObj.getContentType() ); InputStream data=wbObj.getData(); int c=data.read(); while (c>=0 ){ out.write(c); } } }
Questions? Contact: Michael Chaney Technical Director ChainLink Networking Solutions, Inc. mikec@chainlink.com