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

📄 commcontrollerservlet.java

📁 Sun公司Dream项目
💻 JAVA
字号:
/*
 * The contents of this file are subject to the terms
 * of the Common Development and Distribution License
 * (the "License").  You may not use this file except
 * in compliance with the License.
 *
 * You can obtain a copy of the license at
 * http://www.opensource.org/licenses/cddl1.php
 * See the License for the specific language governing
 * permissions and limitations under the License.
 *
 * When distributing Covered Code, include this CDDL
 * HEADER in each file and include the License file at
 * http://www.opensource.org/licenses/cddl1.php.  If 
 * applicable, add the following below this CDDL HEADER, 
 * with the fields enclosed by brackets "[]" replaced 
 * with your own identifying information: 
 * Portions Copyright [yyyy]
 * [name of copyright owner]
 */ 

/*
 * $(@)CommControllerServlet.java $Revision: 1.1.1.1 $ $Date: 2006/03/15 13:12:10 $
 * 
 * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
 */


package com.sun.sjc.idtv.vod.server.comm;



import java.io.*; 

import java.sql.*;

import java.util.*; 

import javax.servlet.*; 

import javax.naming.*; 

import javax.servlet.http.*; 

import javax.rmi.PortableRemoteObject;

import javax.ejb.*; 



import com.sun.sjc.idtv.vod.server.subscriber.*;

import com.sun.sjc.idtv.vod.server.mediacatalog.*;

import com.sun.sjc.idtv.vod.server.billing.*;

import com.sun.sjc.idtv.vod.server.auditing.*;

import com.sun.sjc.idtv.vod.shared.data.*;



/**

 * This servlet is responsible for throwing the html pages for the HelloWorld application.

 */

public class CommControllerServlet extends CalledServiceServlet {  



    SubscriberManagementSystem sms;

    SubscriberManagementSystemHome smsHome;

    MediaCatalog mediacat;

    MediaCatalogHome mediacatHome;

    BillingEngine billing;

    BillingEngineHome billingHome;

    AuditLog auditer;

    AuditLogHome auditerHome;

 

    InitialContext initContext = null; 

    Hashtable env = new java.util.Hashtable(1); 



    public void init(ServletConfig config) throws ServletException { 



        try {

	    super.init(config);

            initContext = new javax.naming.InitialContext(); 



            String JNDIName = "java:comp/env/ejb/SubscriberManagementSystem"; 

            Object objref = initContext.lookup(JNDIName); 

            smsHome = (SubscriberManagementSystemHome)PortableRemoteObject.narrow(objref, SubscriberManagementSystemHome.class);

            sms = smsHome.create();  



	    JNDIName = "java:comp/env/ejb/MediaCatalog"; 

	    objref = initContext.lookup(JNDIName); 

            mediacatHome = (MediaCatalogHome)PortableRemoteObject.narrow(objref, MediaCatalogHome.class);

            mediacat = mediacatHome.create();  



	    JNDIName = "java:comp/env/ejb/BillingEngine"; 

	    objref = initContext.lookup(JNDIName); 

            billingHome = (BillingEngineHome)PortableRemoteObject.narrow(objref, BillingEngineHome.class);

            billing = billingHome.create();  



	    JNDIName = "java:comp/env/ejb/AuditLog"; 

	    objref = initContext.lookup(JNDIName); 

            auditerHome = (AuditLogHome)PortableRemoteObject.narrow(objref, AuditLogHome.class);

            auditer = auditerHome.create();  



	} catch (Exception e) {

	    System.out.println("Exception: " + e.toString());

	    e.printStackTrace();

	}

    }



    public void destroy() {



	sms = null;

	mediacat = null;

	billing = null;

	auditer = null;

    }



    public Serializable call(HttpServletRequest request, HttpServletResponse response, Serializable param) throws Exception {

		

	// redirect call

	String path = request.getPathInfo();



        /*

	System.out.println("---------------------------------------------------------");

	System.out.println("request uri: " + request.getRequestURI());

	System.out.println("servlet path: " + request.getServletPath());

	System.out.println("path info: " + request.getPathInfo());

	System.out.println("query string: " + request.getQueryString());

         */



        if (path.equals("/method=getSubscriberList")) {

	    Subscriber[] subs = sms.getSubscriberList((String) param);

	    return subs;

	} else if (path.equals("/method=authenticate")) {

	    Subscriber subs = sms.authenticate((Subscriber) param);

	    return subs;

	} else if (path.equals("/method=getSplashInfo")) {

	    String[] info = mediacat.getSplashInfo();

	    return info;

	} else if (path.equals("/method=getMovieList")) {

	    int catid = ((Integer) param).intValue();

	    Movie[] movies = mediacat.getMovieList(catid);

	    return movies;

	} else if (path.equals("/method=getMovieMetadata")) {

	    long movieid = ((Long) param).longValue();

	    Movie movie = mediacat.getMovieMetadata(movieid);

	    return movie;

	} else if (path.equals("/method=rentMovie")) {

	    Vector v = (Vector) param;

	    Subscriber subs = (Subscriber) v.elementAt(0);

	    Movie movie = (Movie) v.elementAt(1);

	    boolean ok = billing.rentMovie(subs, movie);

	    return new Boolean(ok);

	} else if (path.equals("/method=storeBookmark")) {

	    Vector v = (Vector) param;

	    Subscriber subs = (Subscriber) v.elementAt(0);

	    Rental rental = (Rental) v.elementAt(1);

	    sms.storeBookmark(subs, rental);

	}

	return null; // if we get a wrong url

    }



   /**

    * Returns the servlet info as a String.

    * @return returns the servlet info as a String.

    */

    public String getServletInfo() { 

        return "/VOD/CommControllerServlet"; 

    } 

} 

⌨️ 快捷键说明

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