その他のコンテンツ・ソースを使用したマルチメディア・コンテンツのロード

その他のコンテンツ・ソースを遅延ロードで使用するには、OrdContentSourceインタフェースを実装するカスタムのコンテンツ・ソース・クラスを記述する必要があります。次のコードは、URLSourceクラスの記述方法の例を示しています。

  package user;
import oracle.ord.im.OrdContentSource; import java.net.URL; import java.io.InputStream; import java.io.IOException;
public class URLSource implements OrdContentSource { private URL m_url = null; private String m_mimeType = null; public URLSource(URL url) { m_url = url; } public void setURL(URL url) { m_url = url; } public URL getURL() { return m_url; } // // This is the most important method you need to implement. // The Business Components uses this method to get the InputStream // to read from the content source. // public InputStream getInputStream() throws IOException { return m_url.openStream(); } // // If the content length is undetermined, you need to return -1. // Otherwise, return the content length of the source. // public int getContentLength() throws IOException { return -1; } public void setMimeType(String mimeType) { m_mimeType = mimeType; } public String getMimeType() { return m_mimeType; } }

これで、URLSourceを使用してURLからデータベースにコンテンツをロードできます。


  URL url = new URL("http://www.oracle.com/logo.gif");
  Row row = viewObject.createRow();
  OrdImageDomain img = new OrdImageDomain();
  img.setContentSource(new URLSource(url));
  row.setAttribute("Image", img);
  row.setAttribute("Id", 1);
  vo.insertRow(row);
  appModule.getTransaction().commit();    

実際には、コンテンツのロードはトランザクションをコミットした時点、または変更をポストした時点で行われます。

  1. URLのインスタンスを作成します。
  2. ビジネス・コンポーネント・ビュー・オブジェクトに、コンテンツをアップロードする行を作成します。
  3. コンテンツ・タイプに適したinterMediaドメイン・クラス(OrdImageDomainOrdVideoDomainOrdDocDomainまたはOrdAudioDomain)のインスタンスを作成します。
  4. URLインスタンスからURLSourceのインスタンスを作成します。
  5. 遅延ロードのsetContentSource()メソッドを、URLSourceインスタンスを使用してコールします。
  6. 行に対してビジネス・コンポーネント・メソッドをコールし、新規ドメインの属性を指定します。
  7. 行を挿入してコミットします。

遅延ロードまたは即時ロードを使用したマルチメディア・コンテンツのロードについて
マルチメディア・コンテンツを含むレコードの挿入
マルチメディア・コンテンツを含むレコードの更新方法

 

 

Copyright © 1997, 2004, Oracle. All rights reserved.