📄 videoareaclient.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.VideoAreaInfo;
import com.singnet.video.ejb.VideoArea;
import com.singnet.video.ejb.VideoAreaHome;
public class VideoAreaClient {
private VideoArea videoArea = null;
private VideoAreaHome videoAreaHome = null;
//Construct the EJB test client
public VideoAreaClient() {
initialize();
videoArea=create();
}
public void initialize() {
try {
//get naming context
Context context = getInitialContext();
//look up jndi name
Object ref = context.lookup("VideoArea");
//look up jndi name and cast to Home interface
videoAreaHome = (VideoAreaHome) PortableRemoteObject.narrow(ref, VideoAreaHome.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 VideoArea create() {
try {
videoArea = videoAreaHome.create();
} catch (Exception e) {
e.printStackTrace();
}
return videoArea;
}
//----------------------------------------------------------------------------
// Methods that use Remote interface methods to access data through the bean
//----------------------------------------------------------------------------
public boolean addVideoAreaInfo(VideoAreaInfo videoAreainfo) {
boolean returnValue = false;
if (videoArea == null) {
System.out.println("Error in addVideoAreaInfo(): ");
return returnValue;
}
try {
returnValue = videoArea.addVideoArea(videoAreainfo);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public boolean editVideoAreaInfo(VideoAreaInfo videoAreainfo) {
boolean returnValue = false;
if (videoArea == null) {
System.out.println("Error in editVideoAreaInfo(): ");
return returnValue;
}
try {
returnValue = videoArea.editVideoArea(videoAreainfo);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public boolean deleteVideoAreaInfo(String id) {
boolean returnValue = false;
if (videoArea == null) {
System.out.println("Error in deleteVideoAreaInfo(): " );
return returnValue;
}
try {
returnValue = videoArea.deleteVideoArea(id);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public ArrayList queryVideoAreaInfo(Pager pager) {
ArrayList returnValue = null;
if (videoArea == null) {
System.out.println("Error in queryVideoAreaInfo(): " );
return returnValue;
}
try {
returnValue = videoArea.queryVideoArea(pager);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public int getTotal(Pager pager) {
int returnValue = 0;
if (videoArea == null) {
System.out.println("Error in getTotal(): " );
return returnValue;
}
try {
returnValue = videoArea.getTotal(pager);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public VideoAreaInfo getVideoAreaById(String id) {
VideoAreaInfo returnValue = null;
if (videoArea == null) {
System.out.println("Error in getVideoAreaInfoByUid(): "
);
return returnValue;
}
try {
returnValue = videoArea.getVideoAreaById(id);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public VideoAreaInfo getVideoAreaByAreaname(String Areaname) {
VideoAreaInfo returnValue = null;
if (videoArea == null) {
System.out.println("Error in getVideoAreaInfoByUid(): "
);
return returnValue;
}
try {
returnValue = videoArea.getVideoAreaByAreaname(Areaname);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
//Main method
public static void main(String[] args) {
VideoAreaClient client = new VideoAreaClient();
// 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 + -