📄 musicviewbd.java
字号:
package music.web;
import java.io.FileNotFoundException;
import java.rmi.RemoteException;
import java.util.*;
import javax.ejb.*;
import javax.naming.*;
import music.ejb.*;
import music.shared.*;
/**
* MusicViewEjb 业务代表类
*/
public class MusicViewBD {
private static final String JNDI_MUSIC_VIEW = "ejb/MusicView";
private static MusicViewRemoteHome home = null;
private static Object syn = new Object();
private static MusicViewRemoteHome getHome() {
if(home==null) {
synchronized(syn) {
if(home==null) {
Hashtable ht = new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = null;
try {
ctx = new InitialContext(ht);
Object obj = ctx.lookup(JNDI_MUSIC_VIEW);
home = (MusicViewRemoteHome)javax.rmi.PortableRemoteObject.narrow(obj, MusicViewRemoteHome.class);
}
catch(NamingException ne) {
// Error log:
System.out.println("-- Exception in lookup ejb: ejb/AccountManage --");
ne.printStackTrace();
}
finally {
try { ctx.close(); } catch(Exception e) {}
}
}
}
}
return home;
}
public static String download(int id)
throws ApplicationException, IllegalArgumentException, FileNotFoundException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.download(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static AlbumVO getAlbum(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getAlbum(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static Collection getAlbums(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getAlbums(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static ArtistVO getArtist(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getArtist(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static Collection getArtists(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getArtists(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static Collection getCategories(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getCategories(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static String getLyric(int id)
throws ApplicationException, IllegalArgumentException, LyricNotFoundException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getLyric(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static Collection getSongs(int id)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.getSongs(id);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static int rate(int songId, int mark)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.rate(songId, mark);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e){}
}
}
public static Collection searchSongs(String title)
throws ApplicationException, IllegalArgumentException
{
MusicViewRemote view = null;
try {
view = getHome().create();
return view.searchSongs(title);
}
catch(RemoteException re) {
throw new ApplicationException(re);
}
catch(CreateException re) {
throw new ApplicationException(re);
}
finally {
try { view.remove(); } catch(Exception e) {}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -