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 BC4J framework 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();
実際には、コンテンツのロードはトランザクションをコミットした時点、または変更をポストした時点で行われます。
OrdImageDomain
、OrdVideoDomain
、OrdDocDomain
またはOrdAudioDomain
)のインスタンスを作成します。setContentSource()
メソッドを、URLSourceインスタンスを使用してコールします。遅延ロードまたは即時ロードを使用したマルチメディア・コンテンツのロードについて
マルチメディア・コンテンツを含むレコードの挿入
マルチメディア・コンテンツを含むレコードの更新方法