Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright 2010 Eric Dalquist Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package com.googlecode.shutdownlistener;
Connects to the org.jasig.portal.stats.shutdown.ShutdownHandler and passes the first parameter passed on the command line. Any output from the handler is written to standard out.

Eric Dalquist
$Revision: 6 $
public class ShutdownUtility {
    public static void main(String[] argsthrows Exception {
        final ShutdownConfiguration config = ShutdownConfiguration.getInstance();
        final String command;
        if (args.length > 0) {
            command = args[0];
        else {
            command = config.getStatusCommand();
        ..println("Calling " + config.getHost() + ":" + config.getPort() + " with command: " + command);
        final InetAddress hostAddress = InetAddress.getByName(config.getHost());
        final Socket shutdownConnection = new Socket(hostAddressconfig.getPort());
        try {
            final BufferedReader reader = new BufferedReader(new InputStreamReader(shutdownConnection.getInputStream()));
            final PrintStream writer = new PrintStream(shutdownConnection.getOutputStream());
            try {
                while (true) {
                    final String line = reader.readLine();
                    if (line == null) {
            finally {
        finally {
            try {
            catch (IOException ioe) {
New to GrepCode? Check out our FAQ X