[RFC][Icedtea-Web]: minor refactoring + dead code removal
Deepak Bhole
dbhole at redhat.com
Mon Feb 28 14:27:26 PST 2011
* Denis Lila <dlila at redhat.com> [2011-02-28 17:18]:
> Is it ok now?
>
> ChangeLog:
>
> +2011-02-28 Denis Lila <dlila at redhat.com>
> +
> + * plugin/icedteanp/java/sun/applet/PluginMain.java
> + (redirectStreams, streamHandler, securityContext) make them local.
> + (theVersion): make it private.
> + (PluginMain): make it private. Empty the body.
> + (main): Do all the work that used to be in PluginMain.
> + (connect): make it static, and now it returns a PluginStreamHandler
> + instead of setting a static variable.
> + (messageAvailable, getMessage): Remove.
> +
>
Yep, looks good. Okay for head.
Cheers,
Deepak
> Thank you,
> Denis.
>
> ----- Original Message -----
> > * Denis Lila <dlila at redhat.com> [2011-02-28 16:35]:
> > > Hi.
> > >
> > > This makes PluginMain non-instantiable since none of its
> > > created instances were ever used. It also removes a couple
> > > of functions that were never called, and turns into local
> > > variables a few variables that were only used in one place.
> > >
> > > Ok to push?
> > >
> >
> > Please post ChangeLog. See below for additional comments.
> >
> > > Thank you,
> > > Denis.
> >
> > > diff -r 54077eaf4670
> > > plugin/icedteanp/java/sun/applet/PluginMain.java
> > > --- a/plugin/icedteanp/java/sun/applet/PluginMain.java Mon Feb 28
> > > 14:30:39 2011 -0500
> > > +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java Mon Feb 28
> > > 16:23:07 2011 -0500
> > > @@ -85,14 +85,9 @@
> > > public static final String PLUGIN_STDERR_FILE = "java.stderr";
> > > public static final String PLUGIN_STDOUT_FILE = "java.stdout";
> > >
> > > - final boolean redirectStreams =
> > > System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
> > > - static PluginStreamHandler streamHandler;
> > > -
> > > // This is used in init(). Getting rid of this is desirable but
> > > depends
> > > // on whether the property that uses it is necessary/standard.
> > > - public static final String theVersion =
> > > System.getProperty("java.version");
> > > -
> > > - private PluginAppletSecurityContext securityContext;
> > > + private static final String theVersion =
> > > System.getProperty("java.version");
> > >
> > > /**
> > > * The main entry point into AppletViewer.
> > > @@ -105,7 +100,24 @@
> > > }
> > >
> > > try {
> > > - PluginMain pm = new PluginMain(args[0], args[1]);
> > > + PluginStreamHandler streamHandler = connect(args[0], args[1]);
> > > + boolean redirectStreams =
> > > System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
> > > +
> > > + // must be called before JNLPRuntime.initialize()
> > > + JNLPRuntime.setRedirectStreams(redirectStreams);
> > > +
> > > + PluginAppletSecurityContext sc = new
> > > PluginAppletSecurityContext(0);
> > > + sc.prePopulateLCClasses();
> > > + PluginAppletSecurityContext.setStreamhandler(streamHandler);
> > > + AppletSecurityContextManager.addContext(0, sc);
> > > +
> > > + PluginAppletViewer.setStreamhandler(streamHandler);
> > > + PluginAppletViewer.setPluginCallRequestFactory(new
> > > PluginCallRequestFactory());
> > > +
> > > + init();
> > > +
> > > + // Streams set. Start processing.
> > > + streamHandler.startProcessing();
> > > } catch (Exception e) {
> > > e.printStackTrace();
> > > System.err.println("Something very bad happened. I
> > > don't know what to do, so I am going to exit :(");
> > > @@ -113,34 +125,19 @@
> > > }
> > > }
> > >
> > > - public PluginMain(String inPipe, String outPipe) {
> > > -
> > > - connect(inPipe, outPipe);
> > > -
> > > - // must be called before JNLPRuntime.initialize()
> > > - JNLPRuntime.setRedirectStreams(redirectStreams);
> > > -
> > > - securityContext = new PluginAppletSecurityContext(0);
> > > - securityContext.prePopulateLCClasses();
> > > - securityContext.setStreamhandler(streamHandler);
> > > - AppletSecurityContextManager.addContext(0, securityContext);
> > > -
> > > - PluginAppletViewer.setStreamhandler(streamHandler);
> > > - PluginAppletViewer.setPluginCallRequestFactory(new
> > > PluginCallRequestFactory());
> > > -
> > > - init();
> > > -
> > > - // Streams set. Start processing.
> > > - streamHandler.startProcessing();
> > > + private PluginMain() throws Exception {
> > > + throw new Exception("The PluginMain constructor should never,
> > > EVER, be called");
> > > }
> > >
> >
> > Indentation is off in the above.
> >
> > Also, Having a private constructor is enough. I don't think we need to
> > make it throw an exception.
> >
> > Cheers,
> > Deepak
> >
> > > - public void connect(String inPipe, String outPipe) {
> > > + private static PluginStreamHandler connect(String inPipe, String
> > > outPipe) {
> > > + PluginStreamHandler streamHandler = null;
> > > try {
> > > streamHandler = new PluginStreamHandler(new
> > > FileInputStream(inPipe), new
> > > FileOutputStream(outPipe));
> > > PluginDebug.debug("Streams initialized");
> > > } catch (IOException ioe) {
> > > ioe.printStackTrace();
> > > }
> > > + return streamHandler;
> > > }
> > >
> > > private static void init() {
> > > @@ -206,13 +203,4 @@
> > > CookieManager ckManager = new PluginCookieManager();
> > > CookieHandler.setDefault(ckManager);
> > > }
> > > -
> > > - static boolean messageAvailable() {
> > > - return streamHandler.messageAvailable();
> > > - }
> > > -
> > > - static String getMessage() {
> > > - return streamHandler.getMessage();
> > > - }
> > > -
> > > }
> diff -r 54077eaf4670 ChangeLog
> --- a/ChangeLog Mon Feb 28 14:30:39 2011 -0500
> +++ b/ChangeLog Mon Feb 28 17:21:13 2011 -0500
> @@ -1,3 +1,14 @@
> +2011-02-28 Denis Lila <dlila at redhat.com>
> +
> + * plugin/icedteanp/java/sun/applet/PluginMain.java
> + (redirectStreams, streamHandler, securityContext) make them local.
> + (theVersion): make it private.
> + (PluginMain): make it private. Empty the body.
> + (main): Do all the work that used to be in PluginMain.
> + (connect): make it static, and now it returns a PluginStreamHandler
> + instead of setting a static variable.
> + (messageAvailable, getMessage): Remove.
> +
> 2011-02-28 Omair Majid <omajid at redhat.com>
>
> * netx/net/sourceforge/jnlp/resources/Messages.properties: Add Password,
> diff -r 54077eaf4670 plugin/icedteanp/java/sun/applet/PluginMain.java
> --- a/plugin/icedteanp/java/sun/applet/PluginMain.java Mon Feb 28 14:30:39 2011 -0500
> +++ b/plugin/icedteanp/java/sun/applet/PluginMain.java Mon Feb 28 17:21:13 2011 -0500
> @@ -85,14 +85,9 @@
> public static final String PLUGIN_STDERR_FILE = "java.stderr";
> public static final String PLUGIN_STDOUT_FILE = "java.stdout";
>
> - final boolean redirectStreams = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
> - static PluginStreamHandler streamHandler;
> -
> // This is used in init(). Getting rid of this is desirable but depends
> // on whether the property that uses it is necessary/standard.
> - public static final String theVersion = System.getProperty("java.version");
> -
> - private PluginAppletSecurityContext securityContext;
> + private static final String theVersion = System.getProperty("java.version");
>
> /**
> * The main entry point into AppletViewer.
> @@ -105,7 +100,24 @@
> }
>
> try {
> - PluginMain pm = new PluginMain(args[0], args[1]);
> + PluginStreamHandler streamHandler = connect(args[0], args[1]);
> + boolean redirectStreams = System.getenv().containsKey("ICEDTEAPLUGIN_DEBUG");
> +
> + // must be called before JNLPRuntime.initialize()
> + JNLPRuntime.setRedirectStreams(redirectStreams);
> +
> + PluginAppletSecurityContext sc = new PluginAppletSecurityContext(0);
> + sc.prePopulateLCClasses();
> + PluginAppletSecurityContext.setStreamhandler(streamHandler);
> + AppletSecurityContextManager.addContext(0, sc);
> +
> + PluginAppletViewer.setStreamhandler(streamHandler);
> + PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory());
> +
> + init();
> +
> + // Streams set. Start processing.
> + streamHandler.startProcessing();
> } catch (Exception e) {
> e.printStackTrace();
> System.err.println("Something very bad happened. I don't know what to do, so I am going to exit :(");
> @@ -113,34 +125,19 @@
> }
> }
>
> - public PluginMain(String inPipe, String outPipe) {
> -
> - connect(inPipe, outPipe);
> -
> - // must be called before JNLPRuntime.initialize()
> - JNLPRuntime.setRedirectStreams(redirectStreams);
> -
> - securityContext = new PluginAppletSecurityContext(0);
> - securityContext.prePopulateLCClasses();
> - securityContext.setStreamhandler(streamHandler);
> - AppletSecurityContextManager.addContext(0, securityContext);
> -
> - PluginAppletViewer.setStreamhandler(streamHandler);
> - PluginAppletViewer.setPluginCallRequestFactory(new PluginCallRequestFactory());
> -
> - init();
> -
> - // Streams set. Start processing.
> - streamHandler.startProcessing();
> + private PluginMain() {
> + // The PluginMain constructor should never, EVER, be called
> }
>
> - public void connect(String inPipe, String outPipe) {
> + private static PluginStreamHandler connect(String inPipe, String outPipe) {
> + PluginStreamHandler streamHandler = null;
> try {
> streamHandler = new PluginStreamHandler(new FileInputStream(inPipe), new FileOutputStream(outPipe));
> PluginDebug.debug("Streams initialized");
> } catch (IOException ioe) {
> ioe.printStackTrace();
> }
> + return streamHandler;
> }
>
> private static void init() {
> @@ -206,13 +203,4 @@
> CookieManager ckManager = new PluginCookieManager();
> CookieHandler.setDefault(ckManager);
> }
> -
> - static boolean messageAvailable() {
> - return streamHandler.messageAvailable();
> - }
> -
> - static String getMessage() {
> - return streamHandler.getMessage();
> - }
> -
> }
More information about the distro-pkg-dev
mailing list