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

📄 echostringportlet.java

📁 在网格门户portlet上部署网格服务示例程序EchoString
💻 JAVA
字号:
package org.gridlab.gridsphere.portlets;

import org.globus.ogsa.sample.EchoString.EchoStringPortType;
import org.globus.ogsa.sample.EchoString.EchoStringServiceGridLocator;
import org.globus.ogsa.utils.GridServiceFactory;
import org.gridforum.ogsi.Factory;
import org.gridforum.ogsi.LocatorType;
import org.gridforum.ogsi.OGSIServiceGridLocator;
import org.gridlab.gridsphere.portlet.PortletConfig;
import org.gridlab.gridsphere.portlet.PortletRequest;
import org.gridlab.gridsphere.portlet.AbstractPortlet;
import org.gridlab.gridsphere.portlet.PortletException;
import org.gridlab.gridsphere.portlet.PortletResponse;
import org.gridlab.gridsphere.portlet.PortletURI;
import org.gridlab.gridsphere.event.ActionEvent;

import javax.servlet.UnavailableException;
import java.net.URL;
import java.io.IOException;
import java.io.PrintWriter;
import java.rmi.RemoteException;

/**
 * @author <a href="mailto:novotny@aei.mpg.de">Jason Novotny</a>
 * @version $Id: GridCounterPortlet.java,v 1.1 2004/01/03 11:46:32 jdnovotny Exp $
 */
public class EchoStringPortlet extends AbstractPortlet {

  public static final String VIEW_JSP = "/jsp/ogsa/imageprocess/view_imageprocess.jsp";

    // Create a URL for the counter service
  private static final String echostringUrl = "http://127.0.0.1:8080/ogsa/services/sample/EchoString/EchoStringFactoryService";

  private LocatorType locator = null;
  private EchoStringPortType string = null;
  String echostringVal = "hello world";
  public void init(PortletConfig config) throws UnavailableException {
    super.init(config);

      try {
            // Create a grid service handle from the service URL
            URL GSH = new URL(echostringUrl);

            // Get a reference to the CounterService Factory
            OGSIServiceGridLocator gridLocator = new OGSIServiceGridLocator();
            Factory factory = gridLocator.getFactoryPort(GSH);
            GridServiceFactory echostringFactory = new GridServiceFactory(factory);

            // Create a new CounterService instance and get a reference to its Counter PortType.
            locator = echostringFactory.createService();

            EchoStringServiceGridLocator echostringLocator = new EchoStringServiceGridLocator();
            string = echostringLocator.getEchoStringService(locator);

          } catch (Exception e) {
             getPortletLog().error("Unable to create OGSA counter service instance", e);
        }
     }

   public void actionPerformed(ActionEvent evt) throws PortletException {
     PortletRequest req = evt.getPortletRequest();

     /**
     * Return the portlet response associated with this action event
     *
     * @return the <code>PortletResponse</code>
     */

       // System.err.println("in actionPerformed of ImageProcessPortlet");
       // String source="/tmp/1.jpg";
      //  String result="/tmp/2.jpg";

           String echoStr = "hello";
            echoStr = req.getParameter(echoStr);
      //  String sourceStr = req.getParameter(source);
      //  String resultStr = req.getParameter(result);
        //try {
          //  count = Integer.parseInt(countStr);
        //} catch (IllegalArgumentException e) {
            // do nothing
        //}

       String operation = req.getParameter("operation");

        if (operation != null) {
         //   if (operation.equals("Add")) {
                try {
                    System.err.println(" process " + source + " to image");
                   echostringVal = string.echostring(echoStr);
                } catch (RemoteException e) {
                    getPortletLog().error("Failed invoking scale on ImageProcess", e);
                }
            }
            //if (operation.equals("Subtract")) {
              //  try {
                //    counter.subtract(count);
                //} catch (RemoteException e) {
                  //  getPortletLog().error("Failed invoking subtract on counter", e);
                //}
            //}
                  }


  public void doView(PortletRequest req, PortletResponse res) throws IOException, PortletException {

     PortletURI uri = res.createURI();
     uri.addAction("submit");
     req.setAttribute("uri", uri.toString());
     System.out.print("Image Process Successful!!");
        //String counterVal = "0";
       // try {
       //     echostringVal = String.valueOf(counter.getValue());
      //  } catch (RemoteException e) {
      //      getPortletLog().error("Unable to get counter value", e);
      //  }
       req.setAttribute("echostringVal", echostringVal);

      getConfig().getContext().include(VIEW_JSP, req, res);
    }

  public void doHelp(PortletRequest req, PortletResponse res) throws IOException, PortletException {
     PrintWriter out = res.getWriter();
     out.println("This portlet demonstrates the GT3 counter service.");
    }
}
}

⌨️ 快捷键说明

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