Skip to Content.
Sympa Menu

notify-dpml - r1241 - in trunk/main/station: console/src/main/net/dpml/station/console server/src/main/net/dpml/station/server

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1241 - in trunk/main/station: console/src/main/net/dpml/station/console server/src/main/net/dpml/station/server
  • Date: Tue, 21 Mar 2006 09:42:33 +0100

Author: mcconnell
Date: 2006-03-21 09:42:27 +0100 (Tue, 21 Mar 2006)
New Revision: 1241

Added:

trunk/main/station/server/src/main/net/dpml/station/server/ErrorStreamReader.java

trunk/main/station/server/src/main/net/dpml/station/server/OutputStreamReader.java

trunk/main/station/server/src/main/net/dpml/station/server/StreamReader.java
Modified:

trunk/main/station/console/src/main/net/dpml/station/console/StationPlugin.java

trunk/main/station/server/src/main/net/dpml/station/server/RemoteApplication.java
Log:
sync station server with shared output and error readers

Modified:
trunk/main/station/console/src/main/net/dpml/station/console/StationPlugin.java
===================================================================
---
trunk/main/station/console/src/main/net/dpml/station/console/StationPlugin.java
2006-03-21 05:49:27 UTC (rev 1240)
+++
trunk/main/station/console/src/main/net/dpml/station/console/StationPlugin.java
2006-03-21 08:42:27 UTC (rev 1241)
@@ -44,6 +44,8 @@
import net.dpml.station.ApplicationRegistry;
import net.dpml.station.info.ApplicationDescriptor;
import net.dpml.station.server.RemoteApplicationRegistry;
+import net.dpml.station.server.OutputStreamReader;
+import net.dpml.station.server.ErrorStreamReader;

import net.dpml.component.Provider;

@@ -484,10 +486,30 @@
String info = getRawArguments( message, args );
getLogger().debug( info );

- Runtime.getRuntime().exec( args, null );
- getLogger().info( "startup in process." );
+ Process process = Runtime.getRuntime().exec( args, null );
+ getLogger().info( "startup in process" );
+
+ OutputStreamReader output = new OutputStreamReader( getLogger(),
process.getInputStream() );
+ ErrorStreamReader err = new ErrorStreamReader( getLogger(),
process.getErrorStream() );
+ output.setDaemon( true );
+ err.setDaemon( true );
+ output.start();
+ err.start();
+
+ //while( null == getStation( port ) )
+ //{
+ // try
+ // {
+ // Thread.currentThread().sleep( 600 );
+ // }
+ // catch( Exception e )
+ // {
+ // }
+ //}
+
+ getLogger().info( "station started" );
}
-
+
private void processShutdown( Manager manager ) throws Exception
{
getLogger().info( "initiating station shutdown" );

Added:
trunk/main/station/server/src/main/net/dpml/station/server/ErrorStreamReader.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/ErrorStreamReader.java
2006-03-21 05:49:27 UTC (rev 1240)
+++
trunk/main/station/server/src/main/net/dpml/station/server/ErrorStreamReader.java
2006-03-21 08:42:27 UTC (rev 1241)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 net.dpml.station.server;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.rmi.ConnectException;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.EventObject;
+import java.util.EventListener;
+
+import net.dpml.station.info.StartupPolicy;
+import net.dpml.station.info.ApplicationDescriptor;
+
+import net.dpml.component.Component;
+import net.dpml.component.Provider;
+
+import net.dpml.station.Callback;
+import net.dpml.station.ProcessState;
+import net.dpml.station.Application;
+import net.dpml.station.ApplicationException;
+import net.dpml.station.ApplicationListener;
+import net.dpml.station.ApplicationEvent;
+
+import net.dpml.lang.Logger;
+import net.dpml.lang.PID;
+
+/**
+ * Stream reader utility class.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ErrorStreamReader extends StreamReader
+{
+ /**
+ * Creation of a process output reader.
+ * @param input the subprocess input stream
+ */
+ public ErrorStreamReader( Logger logger, InputStream input )
+ {
+ super( logger, input );
+ }
+
+ /**
+ * Start the stream reader.
+ */
+ public void run()
+ {
+ try
+ {
+ InputStreamReader isr = new InputStreamReader( getInputStream()
);
+ BufferedReader reader = new BufferedReader( isr );
+ String line = null;
+ while( ( line = reader.readLine() ) != null )
+ {
+ getLogger().debug( line );
+ }
+ }
+ catch( IOException e )
+ {
+ getLogger().error( "Process read error.", e );
+ }
+ }
+}

Added:
trunk/main/station/server/src/main/net/dpml/station/server/OutputStreamReader.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/OutputStreamReader.java
2006-03-21 05:49:27 UTC (rev 1240)
+++
trunk/main/station/server/src/main/net/dpml/station/server/OutputStreamReader.java
2006-03-21 08:42:27 UTC (rev 1241)
@@ -0,0 +1,86 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 net.dpml.station.server;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.rmi.ConnectException;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.EventObject;
+import java.util.EventListener;
+
+import net.dpml.station.info.StartupPolicy;
+import net.dpml.station.info.ApplicationDescriptor;
+
+import net.dpml.component.Component;
+import net.dpml.component.Provider;
+
+import net.dpml.station.Callback;
+import net.dpml.station.ProcessState;
+import net.dpml.station.Application;
+import net.dpml.station.ApplicationException;
+import net.dpml.station.ApplicationListener;
+import net.dpml.station.ApplicationEvent;
+
+import net.dpml.lang.Logger;
+import net.dpml.lang.PID;
+
+/**
+ * Stream reader utility class.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class OutputStreamReader extends StreamReader
+{
+ /**
+ * Creation of a process output reader.
+ * @param input the subprocess input stream
+ */
+ public OutputStreamReader( Logger logger, InputStream input )
+ {
+ super( logger, input );
+ }
+
+ /**
+ * Start the stream reader.
+ */
+ public void run()
+ {
+ try
+ {
+ InputStreamReader isr = new InputStreamReader( getInputStream()
);
+ BufferedReader reader = new BufferedReader( isr );
+ String line = null;
+ while( ( line = reader.readLine() ) != null )
+ {
+ getLogger().debug( line );
+ }
+ }
+ catch( IOException e )
+ {
+ getLogger().error( "Process read error.", e );
+ }
+ }
+}

Modified:
trunk/main/station/server/src/main/net/dpml/station/server/RemoteApplication.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/RemoteApplication.java
2006-03-21 05:49:27 UTC (rev 1240)
+++
trunk/main/station/server/src/main/net/dpml/station/server/RemoteApplication.java
2006-03-21 08:42:27 UTC (rev 1241)
@@ -271,8 +271,11 @@

}

- OutputStreamReader output = new OutputStreamReader(
m_process.getInputStream() );
- ErrorStreamReader err = new ErrorStreamReader(
m_process.getErrorStream() );
+ Logger logger = getLogger();
+ OutputStreamReader output = new OutputStreamReader( logger,
m_process.getInputStream() );
+ ErrorStreamReader err = new ErrorStreamReader( logger,
m_process.getErrorStream() );
+ output.setDaemon( true );
+ err.setDaemon( true );
output.start();
err.start();

@@ -540,103 +543,4 @@
{
return m_descriptor.getShutdownTimeout() * 1000000;
}
-
- /**
- * Internal abstract class to handle reading of subprocess output
- * and error streams.
- */
- private abstract class StreamReader extends Thread
- {
- private final InputStream m_input;
-
- /**
- * Creation of a new reader.
- * @param input the subprocess input stream
- */
- public StreamReader( InputStream input )
- {
- m_input = input;
- }
-
- /**
- * Return the input stream.
- * @return the subprocess input stream
- */
- protected InputStream getInputStream()
- {
- return m_input;
- }
- }
-
- /**
- * Internal class to handle reading of subprocess output streams.
- */
- private class OutputStreamReader extends StreamReader
- {
- /**
- * Creation of a process output reader.
- * @param input the subprocess input stream
- */
- public OutputStreamReader( InputStream input )
- {
- super( input );
- }
-
- /**
- * Start the stream reader.
- */
- public void run()
- {
- try
- {
- InputStreamReader isr = new InputStreamReader(
getInputStream() );
- BufferedReader reader = new BufferedReader( isr );
- String line = null;
- while( ( line = reader.readLine() ) != null )
- {
- System.out.println( line );
- }
- }
- catch( IOException e )
- {
- getLogger().error( "Process read error.", e );
- }
- }
- }
-
- /**
- * Internal class to handle reading of subprocess output and error
streams.
- */
- private class ErrorStreamReader extends StreamReader
- {
- /**
- * Creation of a process output reader.
- * @param input the subprocess input stream
- */
- public ErrorStreamReader( InputStream input )
- {
- super( input );
- }
-
- /**
- * Start the stream reader.
- */
- public void run()
- {
- try
- {
- InputStreamReader isr = new InputStreamReader(
getInputStream() );
- BufferedReader reader = new BufferedReader( isr );
- String line = null;
- while( ( line = reader.readLine() ) != null )
- {
- System.out.println( line );
- }
- }
- catch( IOException e )
- {
- getLogger().error( "Process read error.", e );
- }
- }
- }
}

Added:
trunk/main/station/server/src/main/net/dpml/station/server/StreamReader.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/StreamReader.java
2006-03-21 05:49:27 UTC (rev 1240)
+++
trunk/main/station/server/src/main/net/dpml/station/server/StreamReader.java
2006-03-21 08:42:27 UTC (rev 1241)
@@ -0,0 +1,87 @@
+/*
+ * Copyright 2005 Stephen J. McConnell.
+ *
+ * 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
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 net.dpml.station.server;
+
+import java.io.IOException;
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.rmi.ConnectException;
+import java.rmi.RemoteException;
+import java.util.Enumeration;
+import java.util.ArrayList;
+import java.util.Properties;
+import java.util.EventObject;
+import java.util.EventListener;
+
+import net.dpml.station.info.StartupPolicy;
+import net.dpml.station.info.ApplicationDescriptor;
+
+import net.dpml.component.Component;
+import net.dpml.component.Provider;
+
+import net.dpml.station.Callback;
+import net.dpml.station.ProcessState;
+import net.dpml.station.Application;
+import net.dpml.station.ApplicationException;
+import net.dpml.station.ApplicationListener;
+import net.dpml.station.ApplicationEvent;
+
+import net.dpml.lang.Logger;
+import net.dpml.lang.PID;
+
+/**
+ * Stream reader utility class.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+abstract class StreamReader extends Thread
+{
+ private final Logger m_logger;
+ private final InputStream m_input;
+
+ /**
+ * Creation of a new reader.
+ * @param input the subprocess input stream
+ */
+ public StreamReader( Logger logger, InputStream input )
+ {
+ m_input = input;
+ m_logger = logger;
+ }
+
+ /**
+ * Return the input stream.
+ * @return the subprocess input stream
+ */
+ protected InputStream getInputStream()
+ {
+ return m_input;
+ }
+
+ /**
+ * Return the assigned logging channel.
+ * @return the logging channel
+ */
+ protected Logger getLogger()
+ {
+ return m_logger;
+ }
+}




  • r1241 - in trunk/main/station: console/src/main/net/dpml/station/console server/src/main/net/dpml/station/server, mcconnell at BerliOS, 03/21/2006

Archive powered by MHonArc 2.6.24.

Top of Page