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

📄 videotypeclient.java

📁 本程序是作者开发的一个宽带娱乐系统的一个模块.
💻 JAVA
字号:
package com.singnet.video.client;

import java.util.ArrayList;
import java.util.Hashtable;

import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.rmi.PortableRemoteObject;

import com.singnet.util.Pager;
import com.singnet.video.VideoTypeInfo;
import com.singnet.video.ejb.VideoType;
import com.singnet.video.ejb.VideoTypeHome;

public class VideoTypeClient {
    private VideoType videoType = null;
    private VideoTypeHome videoTypeHome = null;

    //Construct the EJB test client
    public VideoTypeClient() {
        initialize();
        videoType=create();
    }

    public void initialize() {
        try {

            //get naming context
            Context context = getInitialContext();
            //look up jndi name
            Object ref = context.lookup("VideoType");
            //look up jndi name and cast to Home interface
            videoTypeHome = (VideoTypeHome) PortableRemoteObject.narrow(ref, VideoTypeHome.class);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }

    private Context getInitialContext() throws NamingException {
        Hashtable environment = new Hashtable();

        environment.put(Context.INITIAL_CONTEXT_FACTORY,
                        "org.jnp.interfaces.NamingContextFactory");
        environment.put(Context.URL_PKG_PREFIXES,
                        "org.jboss.naming:org.jnp.interfaces");
        environment.put(Context.PROVIDER_URL, "jnp://localhost:1099");

        return new InitialContext(environment);
    }

    //----------------------------------------------------------------------------
    // Methods that use Home interface methods to generate a Remote interface reference
    //----------------------------------------------------------------------------

    public VideoType create() {
      
        try {
            videoType = videoTypeHome.create();
        } catch (Exception e) {
            e.printStackTrace();
        }
        return videoType;
    }

    //----------------------------------------------------------------------------
    // Methods that use Remote interface methods to access data through the bean
    //----------------------------------------------------------------------------


    public boolean addVideoTypeInfo(VideoTypeInfo videoTypeinfo) {
        boolean returnValue = false;
        if (videoType == null) {
            System.out.println("Error in addVideoTypeInfo(): ");
            return returnValue;
        }
        

        try {
            returnValue = videoType.addVideoType(videoTypeinfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }

    public boolean editVideoTypeInfo(VideoTypeInfo videoTypeinfo) {
        boolean returnValue = false;
        if (videoType == null) {
            System.out.println("Error in editVideoTypeInfo(): ");
            return returnValue;
        }
      
        try {
            returnValue = videoType.editVideoType(videoTypeinfo);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }

    public boolean deleteVideoTypeInfo(String id) {
        boolean returnValue = false;
        if (videoType == null) {
            System.out.println("Error in deleteVideoTypeInfo(): " );
            return returnValue;
        }
       
        try {
            returnValue = videoType.deleteVideoType(id);
        } catch (Exception e) {
            e.printStackTrace();
        
        }
        return returnValue;
    }

    public ArrayList queryVideoTypeInfo(Pager pager) {
        ArrayList returnValue = null;
        if (videoType == null) {
            System.out.println("Error in queryVideoTypeInfo(): " );
            return returnValue;
        }
       
        try {
            returnValue = videoType.queryVideoType(pager);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }

    public int getTotal(Pager pager) {
        int returnValue = 0;
        if (videoType == null) {
            System.out.println("Error in getTotal(): " );
            return returnValue;
        }
        try {
            returnValue = videoType.getTotal(pager);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }

    public VideoTypeInfo getVideoTypeById(String id) {
        VideoTypeInfo returnValue = null;
        if (videoType == null) {
            System.out.println("Error in getVideoTypeInfoByUid(): " 
                               );
            return returnValue;
        }
        try {
            returnValue = videoType.getVideoTypeById(id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }

    public VideoTypeInfo getVideoTypeByTypename(String typename) {
        VideoTypeInfo returnValue = null;
        if (videoType == null) {
            System.out.println("Error in getVideoTypeByTypename(): " 
                               );
            return returnValue;
        }
        try {
            returnValue = videoType.getVideoTypeByTypename(typename);
        } catch (Exception e) {
            e.printStackTrace();
        }
        return returnValue;
    }


    //Main method
    public static void main(String[] args) {
    	VideoTypeClient client = new VideoTypeClient();
        // Use the client object to call one of the Home interface wrappers
        // above, to create a Remote interface reference to the bean.
        // If the return value is of the Remote interface type, you can use it
        // to access the remote interface methods.  You can also just use the
        // client object to call the Remote interface wrappers.
    }
}

⌨️ 快捷键说明

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