⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 simplelsp.java

📁 数字图书馆的互操作接口
💻 JAVA
字号:
package dli2fe.sample;

import dli2fe.DLI2FEException;
/* transport module libraries */
import dli2fe.helpers.*;
/* holder for integer values */
import org.omg.CORBA.IntHolder;

import dli2fe.DLI2FE;
import dli2fe.DublinCore;

/**
 * This is the SimpleLSP application described in the DLI2FE Java tutorial.
 */

public class SimpleLSP implements dli2fe.Searcher, dli2fe.Metadata {

  public void search(
		     int clientSID,
		     dli2fe.XMLObject subcollections,
		     dli2fe.XMLObject query,
		     int numDocs,
		     dli2fe.XMLObject docProps,
		     dli2fe.XMLObject queryOptions,
		     IntHolder expectedTotal,
		     IntHolder serverSID,
		     dli2fe.XMLObject result
		     )
    throws DLI2FEException {

    /* makes sure that the XMLObject passed into query is
     * a DOM-enabled dli2fe.xml.dom.XMLObject and convert it if not */
    System.out.println("Query is:\n" + query.getString());

    /* deliver the result; in a real LSP this would access the underlying collection */
    result.setString("<SearchResult xmlns='" + DLI2FE.Namespace + "' " +
		     "              xmlns:dc='" + DublinCore.Namespace + "'>" +
		     "  <doc>" +
		     "    <DID>1</DID>" +
		     "    <propList>" +
		     "      <dc:Title>Fighting a Wind Mill</dc:Title>" +
		     "      <dc:Creator>Don Quichote</dc:Creator>" +
		     "    </propList>" +
		     "  </doc>" +
		     "  <doc>" +
		     "    <DID>2</DID>" +
		     "    <propList>" +
		     "      <dc:Title>Document Without Creator</dc:Title>" +
		     "    </propList>" +
		     "  </doc>" +
		     "</SearchResult>");

    /* set the total expected number of results */
    expectedTotal.value = 2;
  }

  /* Methods of the source metadata interface */

  public void getSiteMetadata(dli2fe.XMLObject theSiteMetadata) throws DLI2FEException {

    theSiteMetadata.setString("<DLI2FEInterface xmlns='" + DLI2FE.Namespace + "'>" +
		      "  <SearchInterface/>" +
		      "  <MetadataInterface/>" +
		      "</DLI2FEInterface>");
  }

  public void getAttributeInfo(String ctrlName, dli2fe.XMLObject attributeInfo) throws DLI2FEException {

    attributeInfo.setString("<subcolInfo xmlns='" + DLI2FE.Namespace + "'>" +
			 "  <subcol>" +
			 "    <subcolName>Dummy-Collection</subcolName>" +
			 "    <subcolDesc>This collection always returns two results independent from the stated query</subcolDesc>" +
			 "    <defaultSubcol/>" +
			 "    <queryLangs/>" +
			 "  </subcol>" +
			 "</subcolInfo>");
  }

  public String toString() {
    return "SimpleLSP";
  }

  public static void main(String args[]) throws Exception {

    /* Instantiate an DLI2FE/DASL transport module
     * This also starts the server on the given port */

//    if(args.length != 1) {
//      System.err.println("Usage: java dli2fe.sample.SimpleLSP <port>");
//      System.exit(1);
//    }

    SimpleLSP lsp = new SimpleLSP();

    try {
      ServerCORBATransport t2 = new ServerCORBATransport();
      t2.addLSP(lsp);
    } catch (NoClassDefFoundError err) {}
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -