애플릿의 배포를 제어하는 경우 (즉, 애플릿을 호스트하는 웹 페이지) 사용자가 직접 애플릿 시작 프로그램을 작성할 수 있습니다. 실행 프로그램은 실제 애플릿에 사용자 정의 환경을 제공하는 랩퍼로 작동합니다. 런처는 실제 애플릿을 인스턴스화하고 애플릿 환경 (AppletStub, AppletContext)의 사용자 정의 된 버전을 전달합니다. 사용자 정의 환경은 AudioClip을 "아무 것도하지 않는"인터페이스로 구현합니다. 오디오 않으려면
, 당신은이 같은을 AppletContext을 무시할 수 :
class CustomAppletContext implements AppletContext
{
AppletContext realContext;
// most methods delegate to the real context, either directly, or with a little modification to hide the fact that we are using this launcher
public void setStatus(String status)
{
realContext.setStatus(status);
}
// override the getAudioClip to return a dummy clip
public AudioClip getAudioClip(URl url)
{
return new DummyAudioClip();
}
}
// An AudioClip implementation that does nothing
class DummyAudioClip implements AudioClip
{
public void loop() { }
public void play() { }
public void stop() { }
}
이 때문에 애플릿이
class CustomAppletStub implements AppletStub
{
AppletStub realStub;
public AppletContext getAppletContext()
{
return new CustomAppletContext(realStub.getAppletContext());
}
}
그리고, 실행기에서을 AppletContext를 얻을 곳 우리는 또한,의 AppletStub를 오버라이드 (override) :
class AppletLauncher extends Applet
{
private Applet realApplet = new NoisyApplet();
// delegate most methods to the applet, but override the stub, to inject our
// AppletContext and AudioClip implementation
public void setAppletStub(AppletStub stub)
{
realApplet.setAppletStub(new CustomAppletStub(stub));
}
}
그것은 많은 코드처럼 보이지만 그냥 AF 정말 ew 클래스와 주로 DummyAudioClip 구현을 삽입하기위한 배선을 포함합니다.
HTH!
이것은 프로그래밍 질문보다 Linux 구성 질문과 비슷합니다. – Pool