📄 musicsongfileclient.java
字号:
package com.singnet.music.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.music.MusicSongFileInfo;
import com.singnet.music.ejb.MusicSongFile;
import com.singnet.music.ejb.MusicSongFileHome;
import com.singnet.util.Pager;
public class MusicSongFileClient {
private MusicSongFile musicSongFile = null;
private MusicSongFileHome musicSongFileHome = null;
//Construct the EJB test client
public MusicSongFileClient() {
initialize();
musicSongFile=this.create();
}
public void initialize() {
try {
//get naming context
Context context = getInitialContext();
//look up jndi name
Object ref = context.lookup("MusicSongFile");
//look up jndi name and cast to Home interface
musicSongFileHome = (MusicSongFileHome) PortableRemoteObject.narrow(
ref, MusicSongFileHome.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 MusicSongFile create() {
try {
musicSongFile = musicSongFileHome.create();
} catch (Exception e) {
e.printStackTrace();
}
return musicSongFile;
}
//----------------------------------------------------------------------------
// Methods that use Remote interface methods to access data through the bean
//----------------------------------------------------------------------------
public boolean addMusicSongFileInfo(MusicSongFileInfo musicSongFileInfo) {
boolean returnValue = false;
if (musicSongFile == null) {
System.out.println("Error in addMusicSongFileInfo(): "
);
return returnValue;
}
try {
returnValue = musicSongFile.addMusicSongFileInfo(musicSongFileInfo);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public boolean editMusicSongFileInfo(MusicSongFileInfo musicSongFileInfo) {
boolean returnValue = false;
if (musicSongFile == null) {
System.out.println("Error in editMusicSongFileInfo(): "
);
return returnValue;
}
try {
returnValue = musicSongFile.editMusicSongFileInfo(musicSongFileInfo);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public boolean deleteMusicSongFileInfo(String id) {
boolean returnValue = false;
if (musicSongFile == null) {
System.out.println("Error in deleteMusicSongFileInfo(): "
);
return returnValue;
}
try {
returnValue = musicSongFile.deleteMusicSongFileInfo(id);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public MusicSongFileInfo queryMusicSongFileInfoById(String id) {
MusicSongFileInfo returnValue = null;
if (musicSongFile == null) {
System.out.println("Error in getMusicSongFileInfoById(): "
);
return returnValue;
}
try {
returnValue = musicSongFile.queryMusicSongFileInfoById(id);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
public ArrayList queryMusicSongFileInfo(String zjid ) {
ArrayList returnValue = null;
if (musicSongFile == null) {
System.out.println("Error in queryMusicCommendInfo(): "
);
return returnValue;
}
try {
returnValue = musicSongFile.queryMusicSongFileInfoByZjid(zjid);
} catch (Exception e) {
e.printStackTrace();
}
return returnValue;
}
//Main method
public static void main(String[] args) {
MusicSongFileClient client = new MusicSongFileClient();
// 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 + -