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

📄 testclient.java

📁 关于的java的多媒体课件
💻 JAVA
字号:
package com.javasrc.licenseserver.client;

import javax.naming.InitialContext;
import javax.naming.Context;
import javax.naming.NamingException;
import java.util.Properties;
import com.javasrc.licenseserver.ejb.productmanager.ProductManagerHomeRemote;
import com.javasrc.licenseserver.ejb.productmanager.ProductManagerRemote;

public class TestClient {
    public static void main( String [] args ) 
    {
        try
        {
            Context jndiContext = getInitialContext();
            Object obj=jndiContext.lookup("ProductManagerHomeRemote");
            ProductManagerHomeRemote home = (ProductManagerHomeRemote)
                javax.rmi.PortableRemoteObject.narrow(obj,ProductManagerHomeRemote.class);
            ProductManagerRemote productManager = home.create();
            productManager.addKeyToProduct( "My Product 1", new Integer( 1 ), "My Key" );
            /*
            productManager.addProduct( new Integer( 1 ), "My Product 1" );
            productManager.addProduct( new Integer( 2 ), "My Product 2" );
            productManager.addProduct( new Integer( 3 ), "My Product 3" );
            productManager.removeProduct( "My Product 1" );
            productManager.removeProduct( "My Product 2" );
            productManager.removeProduct( "My Product 3" );
            productManager.addProduct( new Integer( 1 ), "My Product 1" );
            productManager.addProduct( new Integer( 2 ), "My Product 2" );
            productManager.addProduct( new Integer( 3 ), "My Product 3" );
            */
        }
        catch( Exception e )
        {
            e.printStackTrace();
        }
    }
    public static Context getInitialContext()
        throws javax.naming.NamingException {
        Properties p =new Properties();
        p.setProperty( "java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory" );
        p.setProperty( "java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces" );
        p.setProperty( "java.naming.provider.url", "localhost" );
        return new javax.naming.InitialContext(p);
    }
}

⌨️ 快捷键说明

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