Skip to Content.
Sympa Menu

notify-dpml - r1271 - in trunk/main: depot depot/core depot/core/src/main/net/dpml/depot depot/tools/builder/src/main/net/dpml/tools/tasks metro/builder/src/main/net/dpml/metro/builder metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/data/test metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http/impl planet/http/server station station/server station/server/src/main/net/dpml/station/server transit/core/src/main/net/dpml/lang

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: r1271 - in trunk/main: depot depot/core depot/core/src/main/net/dpml/depot depot/tools/builder/src/main/net/dpml/tools/tasks metro/builder/src/main/net/dpml/metro/builder metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/data/test metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http/impl planet/http/server station station/server station/server/src/main/net/dpml/station/server transit/core/src/main/net/dpml/lang
  • Date: Mon, 27 Mar 2006 09:28:36 +0200

Author: mcconnell
Date: 2006-03-27 09:28:04 +0200 (Mon, 27 Mar 2006)
New Revision: 1271

Added:
trunk/main/depot/core/src/main/net/dpml/depot/LogStatement.java
Modified:
trunk/main/depot/core/build.xml
trunk/main/depot/core/src/main/net/dpml/depot/DepotHandler.java
trunk/main/depot/module.xml

trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/FeatureTask.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentDecoder.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java

trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeEncoder.java

trunk/main/metro/component/src/main/net/dpml/component/ControllerContext.java
trunk/main/metro/component/src/main/net/dpml/component/InitialContext.java
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicy.java

trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java

trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java

trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java

trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
trunk/main/planet/http/impl/build.xml
trunk/main/planet/http/server/project.xml
trunk/main/station/module.xml
trunk/main/station/server/build.xml

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

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

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

trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
trunk/main/transit/core/src/main/net/dpml/lang/PID.java
Log:
1. update feature task to handle reoslution of link uris
2. update depot to reference links in preference to full qualified artifacts
3. replace rmi based logging aggregation with socket-based equivalent
4. replace InfoDescriptor.getLifestyle() with
InfoDescriptor.getLifestylePolicy()
5. correct lifestyle policy handling in the model implementation
6. improve PID class implementation


Modified: trunk/main/depot/core/build.xml
===================================================================
--- trunk/main/depot/core/build.xml 2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/depot/core/build.xml 2006-03-27 07:28:04 UTC (rev 1271)
@@ -14,13 +14,13 @@
<filter token="TRANSIT-PATH" value="${transit.short.filename}"/>
<filter token="DEPOT-MAIN-CLASS" value="net.dpml.depot.Main" />
<filter token="DEPOT-CLASSLOADER-CLASS"
value="net.dpml.transit.SystemClassLoader" />
- <x:filter token="TRANSIT-CONSOLE-URI"
ref="dpml/transit/dpml-transit-console" feature="uri" type="part"/>
+ <x:filter token="DEPOT-CONSOLE-URI" feature="uri" type="jar"/>
<x:filter token="TRANSIT-CORE-URI" ref="dpml/transit/dpml-transit-main"
feature="uri" type="jar"/>
- <x:filter token="DEPOT-CONSOLE-URI" feature="uri" type="jar"/>
- <x:filter token="DEPOT-BUILDER-URI" ref="dpml/depot/dpml-library-build"
feature="uri" type="part"/>
- <x:filter token="DEPOT-EXEC-URI" ref="dpml/station/dpml-station-exec"
feature="uri" type="part"/>
- <x:filter token="DEPOT-STATION-URI"
ref="dpml/station/dpml-station-console" feature="uri" type="part"/>
- <x:filter token="DEPOT-STATION-SERVER-URI"
ref="dpml/station/dpml-station-server" feature="uri" type="part"/>
+ <x:filter token="TRANSIT-CONSOLE-URI"
ref="dpml/transit/dpml-transit-console" feature="uri" type="part"
alias="true"/>
+ <x:filter token="DEPOT-BUILDER-URI" ref="dpml/depot/dpml-library-build"
feature="uri" type="part" alias="true"/>
+ <x:filter token="DEPOT-EXEC-URI" ref="dpml/station/dpml-station-exec"
feature="uri" type="part" alias="true"/>
+ <x:filter token="DEPOT-STATION-URI"
ref="dpml/station/dpml-station-console" feature="uri" type="part"
alias="true"/>
+ <x:filter token="DEPOT-STATION-SERVER-URI"
ref="dpml/station/dpml-station-server" feature="uri" type="part"
alias="true"/>
</target>

<!--

Modified: trunk/main/depot/core/src/main/net/dpml/depot/DepotHandler.java
===================================================================
--- trunk/main/depot/core/src/main/net/dpml/depot/DepotHandler.java
2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/depot/core/src/main/net/dpml/depot/DepotHandler.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Stephen McConnell.
+ * Copyright 2005-2006 Stephen McConnell.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,12 @@

package net.dpml.depot;

-import java.net.URL;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.Socket;
+import java.net.SocketException;
import java.rmi.RemoteException;
import java.util.logging.Handler;
import java.util.logging.LogRecord;
@@ -36,22 +41,40 @@
{
private static final PID ID = new PID();

- private final LoggingService m_system;
+ private final Socket m_socket;
+ //private final ObjectOutputStream m_stream;

/**
* Creation of a new handler instance.
- * @exception Exception if an error occurs during resolution of the
logging service
+ * @exception Exception if an error occurs
*/
public DepotHandler() throws Exception
{
- m_system = getLoggingService();
+ this( "localhost", 2020 );
}
+
+ /**
+ * Creation of a new handler instance.
+ * @exception Exception if an error occurs
+ */
+ public DepotHandler( String host, int port ) throws Exception
+ {
+ m_socket = new Socket( host, port );
+ }

/**
* Flush the handler.
*/
public void flush()
{
+ //try
+ //{
+ // m_stream.flush();
+ //}
+ //catch( Exception e )
+ //{
+ // e.printStackTrace();
+ //}
}

/**
@@ -59,40 +82,42 @@
*/
public void close()
{
+ try
+ {
+ m_socket.close();
+ }
+ catch( Exception e )
+ {
+ e.printStackTrace();
+ }
}

/**
* Publish a log record.
* @param record the log record
*/
- public void publish( LogRecord record )
+ public synchronized void publish( LogRecord record )
{
- try
+ if( m_socket.isClosed() )
{
- m_system.log( ID, record );
+ return;
}
- catch( RemoteException e )
+ try
{
- System.err.println( e.toString() );
+ OutputStream output = m_socket.getOutputStream();
+ ObjectOutputStream stream = new ObjectOutputStream( output );
+ LogStatement statement = new LogStatement( ID, record );
+ stream.writeObject( statement );
+ stream.flush();
}
- }
-
- private LoggingService getLoggingService() throws Exception
- {
- ClassLoader classloader =
Thread.currentThread().getContextClassLoader();
- Thread.currentThread().setContextClassLoader(
getClass().getClassLoader() );
- try
+ catch( SocketException e )
{
- String key = "registry:" + LoggingService.LOGGING_KEY;
- String remote = System.getProperty( "dpml.logging.service", key
);
- URL url = new URL( null, remote, new
net.dpml.transit.registry.Handler() );
- return (LoggingService) url.getContent();
+ //System.out.println( e.toString() );
}
- finally
+ catch( Exception e )
{
- Thread.currentThread().setContextClassLoader( classloader );
+ e.printStackTrace();
}
}
-
}


Added: trunk/main/depot/core/src/main/net/dpml/depot/LogStatement.java
===================================================================
--- trunk/main/depot/core/src/main/net/dpml/depot/LogStatement.java
2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/depot/core/src/main/net/dpml/depot/LogStatement.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2006 Stephen 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.depot;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.ObjectOutputStream;
+import java.io.Serializable;
+import java.net.Socket;
+import java.rmi.RemoteException;
+import java.util.logging.Handler;
+import java.util.logging.LogRecord;
+import java.util.logging.Level;
+
+import net.dpml.lang.PID;
+import net.dpml.lang.LoggingService;
+
+/**
+ * Datastructure holding a log record and process identifier.
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public final class LogStatement implements Serializable
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ private final PID m_pid;
+ private final LogRecord m_record;
+
+ public LogStatement( PID pid, LogRecord record )
+ {
+ m_pid = pid;
+ m_record = record;
+ }
+
+ public PID getPID()
+ {
+ return m_pid;
+ }
+
+ public LogRecord getLogRecord()
+ {
+ return m_record;
+ }
+
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else if( other instanceof LogStatement )
+ {
+ LogStatement statement = (LogStatement) other;
+ if( !m_pid.equals( statement.m_pid ) )
+ {
+ return false;
+ }
+ else
+ {
+ return m_record.equals( statement.m_record );
+ }
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ public int hashCode()
+ {
+ int hash = m_pid.hashCode();
+ hash ^= m_record.hashCode();
+ return hash;
+ }
+}
+

Modified: trunk/main/depot/module.xml
===================================================================
--- trunk/main/depot/module.xml 2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/depot/module.xml 2006-03-27 07:28:04 UTC (rev 1271)
@@ -64,6 +64,7 @@
<project name="dpml-depot-console" basedir="core">
<properties>
<property name="project.jar.main.class" value="net.dpml.depot.Main"/>
+ <property name="project.test.fork" value="true"/>
</properties>
<types>
<type id="jar"/>

Modified:
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/FeatureTask.java
===================================================================
---
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/FeatureTask.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/depot/tools/builder/src/main/net/dpml/tools/tasks/FeatureTask.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -43,7 +43,7 @@
private boolean m_windows = true;
private boolean m_flag = false; // os not set
private String m_type; // optional - used to select type when resolving
uris
- private boolean m_alias = false; // used when resolving filenames
+ private boolean m_alias = false; // used when resolving uris

/**
* Set the key of the target project or resource description from which
features will be
@@ -193,8 +193,27 @@
}
else
{
- Artifact artifact = resource.getArtifact( m_type );
- return artifact.toURI().toString();
+ if( m_alias )
+ {
+ Artifact artifact = resource.getArtifact( m_type );
+ String group = artifact.getGroup();
+ String name = artifact.getName();
+ try
+ {
+ return "link:" + m_type + ":" + group + "/" + name;
+ }
+ catch( Exception e )
+ {
+ final String error =
+ "Unable to resolve link uri for resource: " +
resource;
+ throw new BuildException( error, e, getLocation() );
+ }
+ }
+ else
+ {
+ Artifact artifact = resource.getArtifact( m_type );
+ return artifact.toURI().toString();
+ }
}
}
else if( m_feature.equals( "spec" ) )

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentDecoder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentDecoder.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentDecoder.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -145,9 +145,15 @@

private LifestylePolicy buildLifestylePolicy( Element element ) throws
DecodingException
{
- String defaultValue = LifestylePolicy.TRANSIENT.getName();
- String policy = ElementHelper.getAttribute( element, "lifestyle",
defaultValue );
- return LifestylePolicy.parse( policy );
+ String policy = ElementHelper.getAttribute( element, "lifestyle",
null );
+ if( null != policy )
+ {
+ return LifestylePolicy.parse( policy );
+ }
+ else
+ {
+ return null;
+ }
}

private CollectionPolicy buildCollectionPolicy( Element element ) throws
DecodingException

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeDecoder.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -152,7 +152,7 @@
String classname = ElementHelper.getAttribute( info, "class" );
String version = ElementHelper.getAttribute( info, "version" );
String collection = ElementHelper.getAttribute( info, "collection",
"system" );
- String lifestyle = ElementHelper.getAttribute( info, "lifestyle",
"system" );
+ String lifestyle = ElementHelper.getAttribute( info, "lifestyle",
null );
String threadsafe = ElementHelper.getAttribute( info, "threadsafe",
"unknown" );
Properties properties = buildNestedProperties( info );

@@ -160,12 +160,24 @@
name,
classname,
Version.parse( version ),
- LifestylePolicy.parse( lifestyle ),
+ buildLifestylePolicy( lifestyle ),
CollectionPolicy.parse( collection ),
ThreadSafePolicy.parse( threadsafe ),
properties );
}

+ private LifestylePolicy buildLifestylePolicy( String lifestyle )
+ {
+ if( null == lifestyle )
+ {
+ return null;
+ }
+ else
+ {
+ return LifestylePolicy.parse( lifestyle );
+ }
+ }
+
private ServiceDescriptor[] buildNestedServices( Element root )
{
Element element = ElementHelper.getChild( root, "services" );

Modified:
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeEncoder.java
===================================================================
---
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeEncoder.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/builder/src/main/net/dpml/metro/builder/ComponentTypeEncoder.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -109,7 +109,7 @@
writer.write( " name=\"" + info.getName() );
writer.write( "\"\n" + pad + " class=\"" + info.getClassname() );
writer.write( "\"\n" + pad + " version=\"" + info.getVersion() );
- writer.write( "\"\n" + pad + " lifestyle=\"" +
info.getLifestyle().getName().toLowerCase() );
+ writer.write( "\"\n" + pad + " lifestyle=\"" +
info.getLifestylePolicy().getName().toLowerCase() );
writer.write( "\"\n" + pad + " collection=\"" +
info.getCollectionPolicy().getName().toLowerCase() );
writer.write( "\"\n" + pad + " threadsafe=\"" +
info.getThreadSafePolicy().getName().toLowerCase() );
writer.write( "\"" );

Modified:
trunk/main/metro/component/src/main/net/dpml/component/ControllerContext.java
===================================================================
---
trunk/main/metro/component/src/main/net/dpml/component/ControllerContext.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/component/src/main/net/dpml/component/ControllerContext.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -20,8 +20,6 @@

import java.io.File;

-import net.dpml.lang.Logger;
-
/**
* The ControllerContext declares the runtime context that a controller
* is established within. Controller implementations will typically receive


Modified:
trunk/main/metro/component/src/main/net/dpml/component/InitialContext.java
===================================================================
---
trunk/main/metro/component/src/main/net/dpml/component/InitialContext.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/component/src/main/net/dpml/component/InitialContext.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -27,7 +27,6 @@
import java.util.EventObject;
import java.util.EventListener;

-import net.dpml.lang.Logger;
import net.dpml.transit.Transit;
import net.dpml.transit.Repository;
import net.dpml.transit.monitor.LoggingAdapter;

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/InfoDescriptor.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -290,11 +290,11 @@
}

/**
- * Return the component lifestyle.
+ * Return the component lifestyle policy.
*
- * @return the lifestyle
+ * @return the lifestyle policy
*/
- public LifestylePolicy getLifestyle()
+ public LifestylePolicy getLifestylePolicy()
{
return m_lifestyle;
}

Modified:
trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicy.java
===================================================================
--- trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicy.java
2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/metro/model/src/main/net/dpml/metro/info/LifestylePolicy.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -1,5 +1,5 @@
/*
- * Copyright 2004 Stephen J. McConnell.
+ * Copyright 2004-2006 Stephen J. McConnell.
* Copyright 1999-2004 The Apache Software Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -32,17 +32,17 @@
static final long serialVersionUID = 1L;

/**
- * Weak collection policy.
+ * Transient lifestyle policy.
*/
public static final LifestylePolicy TRANSIENT = new LifestylePolicy(
"transient" );

/**
- * Soft collection policy.
+ * Per-thread lifestyle policy.
*/
public static final LifestylePolicy THREAD = new LifestylePolicy(
"thread" );

/**
- * Hard collection policy.
+ * Singleton lifestyle policy.
*/
public static final LifestylePolicy SINGLETON = new LifestylePolicy(
"singleton" );


Modified:
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/model/src/test/net/dpml/metro/data/test/ComponentDirectiveTestCase.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -192,6 +192,18 @@
}

/**
+ * Test null lifestyle policy returns null.
+ */
+ public void testNullLifestylePolicy()
+ {
+ ComponentDirective directive = new ComponentDirective(
+ m_name, m_activation, m_collection, null, m_classname,
+ m_categories, m_context, m_parameters, m_configuration, m_parts
);
+ LifestylePolicy lifestyle = directive.getLifestylePolicy();
+ assertEquals( "null-lifestyle", null, lifestyle );
+ }
+
+ /**
* Test classname accessor.
*/
public void testClassname()

Modified:
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
===================================================================
---
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/model/src/test/net/dpml/metro/info/test/InfoDescriptorTestCase.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -81,10 +81,34 @@
*/
public void testLifestyle()
{
- assertEquals( m_lifestyle, m_info.getLifestyle() );
+ assertEquals( m_lifestyle, m_info.getLifestylePolicy() );
}

/**
+ * Test the threadsafe default lifestyle policy.
+ */
+ public void testThreadSafeLifestyle()
+ {
+ InfoDescriptor info = new InfoDescriptor(
+ m_name, m_classname, m_version, null, m_collection,
+ ThreadSafePolicy.TRUE, getProperties() );
+ LifestylePolicy lifestyle = info.getLifestylePolicy();
+ assertEquals( "default-threadsafe-lifestyle",
LifestylePolicy.SINGLETON, lifestyle );
+ }
+
+ /**
+ * Test the non-threadsafe default lifestyle policy.
+ */
+ public void testNonThreadSafeLifestyle()
+ {
+ InfoDescriptor info = new InfoDescriptor(
+ m_name, m_classname, m_version, null, m_collection,
+ ThreadSafePolicy.FALSE, getProperties() );
+ LifestylePolicy lifestyle = info.getLifestylePolicy();
+ assertEquals( "default-non-threadsafe-lifestyle",
LifestylePolicy.THREAD, lifestyle );
+ }
+
+ /**
* Test the thread safe policy.
*/
public void testThreadsafeCapable()
@@ -131,7 +155,7 @@
assertEquals( m_name, info.getName() );
assertEquals( m_classname, info.getClassname() );
assertEquals( m_version, info.getVersion() );
- assertEquals( m_lifestyle, info.getLifestyle() );
+ assertEquals( m_lifestyle, info.getLifestylePolicy() );
assertEquals( m_threadsafe, info.getThreadSafePolicy() );
assertEquals( m_collection, info.getCollectionPolicy() );
}

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentHandler.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -249,7 +249,7 @@

m_parts = new DefaultPartsManager( control, this, logger );

- getLogger().debug( "component hander [" + this + "] established" );
+ getLogger().debug( "established " + lifestyle + " handler for [" +
m_class.getName() + "]" );
}


//--------------------------------------------------------------------------

Modified:
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
===================================================================
---
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/runtime/src/main/net/dpml/metro/runtime/DefaultComponentModel.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -122,7 +122,17 @@
}

m_activation = directive.getActivationPolicy();
- m_lifestyle = directive.getLifestylePolicy();
+
+ LifestylePolicy lifestyle = directive.getLifestylePolicy();
+ if( null == lifestyle )
+ {
+ m_lifestyle = m_type.getInfo().getLifestylePolicy();
+ }
+ else
+ {
+ m_lifestyle = lifestyle;
+ }
+
m_collection = directive.getCollectionPolicy();
m_parameters = directive.getParameters();
m_configuration = directive.getConfiguration();

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
===================================================================
--- trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/metro/tools/src/main/net/dpml/metro/tools/CatalogTask.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -487,7 +487,7 @@
writer.write( "\n </td>" );

writer.write( "\n <td>" );
- writer.write( type.getInfo().getLifestyle().getName() );
+ writer.write( type.getInfo().getLifestylePolicy().getName()
);
writer.write( "\n </td>" );

writer.write( "\n </tr>" );
@@ -561,7 +561,7 @@
writer.write( "\n <tr><td class=\"feature\">Name:</td><td>"
+ type.getInfo().getName() + "</td></tr>" );
writer.write( "\n <tr><td
class=\"feature\">Lifestyle:</td><td>"
- + type.getInfo().getLifestyle().getName() + "</td></tr>" );
+ + type.getInfo().getLifestylePolicy().getName() + "</td></tr>"
);
writer.write( "\n <tr><td
class=\"feature\">Thread-Safe:</td><td>"
+ type.getInfo().getThreadSafePolicy() + "</td></tr>" );
writer.write( "\n <tr><td
class=\"feature\">Collection:</td><td>"

Modified:
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
===================================================================
---
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/metro/tools/src/main/net/dpml/metro/tools/ComponentBuilderTask.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -507,7 +507,7 @@
// }
//}

- LifestylePolicy lifestyle = getLifestylePolicy( type );
+ LifestylePolicy lifestyle = getLifestylePolicy();
CollectionPolicy collection = getCollectionPolicy( type );
ActivationPolicy activation = getActivationPolicy();
CategoriesDirective categories = getCategoriesDirective();
@@ -594,27 +594,19 @@
* Return the lifestyle policy declared relative to usage.
* If undefined then default to the lifestyle declared by the component
type.
* Lifestyle policies that may be declared under the 'lifestyle'
attribute of
- * a component are 'request', 'thread' or 'shared'. If 'request' is
supplied
+ * a component are 'transient', 'thread' or 'singleton'. If 'transient'
is supplied
* the assigned lefestyle policy is InfoDescriptor.TRANSIENT resulting in
the
* creation of a new instance per request. If 'thread' is declared the
assigned
* lifestyle policy shall be InfoDescriptor.THREAD in which case a
supplied
* instance will be reused for all requests within the same thread of
execution.
- * If the supplied policy is 'shared' then the established instance will
be
+ * If the supplied policy is 'singleton' then the established instance
will be
* shared across consumers referencing the component.
*
- * @param type the component type
* @return the lifestyle policy
*/
- public LifestylePolicy getLifestylePolicy( Type type )
+ public LifestylePolicy getLifestylePolicy()
{
- if( null == m_lifestyle )
- {
- return type.getInfo().getLifestyle();
- }
- else
- {
- return m_lifestyle;
- }
+ return m_lifestyle;
}

/**

Modified: trunk/main/planet/http/impl/build.xml
===================================================================
--- trunk/main/planet/http/impl/build.xml 2006-03-26 23:37:07 UTC (rev
1270)
+++ trunk/main/planet/http/impl/build.xml 2006-03-27 07:28:04 UTC (rev
1271)
@@ -99,7 +99,7 @@
</state>
<parts>
<component key="requestLog"
- type="net.dpml.http.NCSARequestLog" collection="hard"
lifestyle="singleton" activation="DEMAND">
+ type="net.dpml.http.NCSARequestLog" collection="hard"
activation="DEMAND">
<context>
<entry key="filename"
value="$${dpml.data}/logs/http/request.log"/>
<entry key="append" value="true"/>
@@ -107,7 +107,7 @@
</context>
</component>
<component key="threadPool"
- type="net.dpml.http.BoundedThreadPool" collection="hard"
lifestyle="singleton" activation="DEMAND">
+ type="net.dpml.http.BoundedThreadPool" collection="hard"
activation="DEMAND">
<context>
<entry key="min" value="10"/>
<entry key="max" value="100"/>

Modified: trunk/main/planet/http/server/project.xml
===================================================================
--- trunk/main/planet/http/server/project.xml 2006-03-26 23:37:07 UTC (rev
1270)
+++ trunk/main/planet/http/server/project.xml 2006-03-27 07:28:04 UTC (rev
1271)
@@ -4,13 +4,12 @@
<types>
<component xmlns="artifact:xsd:dpml/lang/dpml-component#1.0"
class="net.dpml.http.Server"
- lifestyle="singleton"
alias="true">
<parts>
<!--
Add a select channel connector to 8080.
-->
- <component key="plain" lifestyle="singleton"
class="net.dpml.http.SelectChannelConnector">
+ <component key="plain" class="net.dpml.http.SelectChannelConnector">
<context>
<entry key="port" value="8080"/>
<entry key="maxIdleTime" value="50000"/>
@@ -20,7 +19,7 @@
<!--
Add a SSL connector to 8443.
-->
- <component key="ssl" lifestyle="singleton"
class="net.dpml.http.SslSocketConnector">
+ <component key="ssl" class="net.dpml.http.SslSocketConnector">
<context>
<entry key="port" value="8443"/>
<entry key="maxIdleTime" value="30000"/>
@@ -32,7 +31,7 @@
<!--
Add a user realm.
-->
- <component key="realm" lifestyle="singleton"
class="net.dpml.http.HashUserRealm">
+ <component key="realm" class="net.dpml.http.HashUserRealm">
<context>
<entry key="name" value="Test Realm"/>
<entry key="URI"
value="local:properties:dpml/planet/http/realm"/>
@@ -41,7 +40,7 @@
<!--
Add a web application.
-->
- <component key="webapp" lifestyle="singleton"
class="net.dpml.http.WebAppContextHandler">
+ <component key="webapp" class="net.dpml.http.WebAppContextHandler">
<context>
<entry key="contextPath" value="/"/>
<entry key="war"
value="link:war:dpml/planet/http/dpml-http-app"/>
@@ -51,7 +50,7 @@
Creation of a HTTP server configured to present static content in
the ${dpml.share}/docs directory.
-->
- <component key="context" lifestyle="singleton"
class="net.dpml.http.ResourceContextHandler">
+ <component key="context"
class="net.dpml.http.ResourceContextHandler">
<context>
<entry key="resourceBase" value="${dpml.share}/docs"/>
<entry key="contextPath" value="/docs"/>
@@ -63,7 +62,7 @@
per-component threads - currently limited to classes declared within
the part classloader).
-->
- <component key="servlets" lifestyle="singleton"
class="net.dpml.http.ServletContextHandler">
+ <component key="servlets"
class="net.dpml.http.ServletContextHandler">
<context>
<entry key="resourceBase" value="${dpml.data}"/>
<entry key="contextPath" value="/data"/>

Modified: trunk/main/station/module.xml
===================================================================
--- trunk/main/station/module.xml 2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/station/module.xml 2006-03-27 07:28:04 UTC (rev 1271)
@@ -19,7 +19,7 @@
<project name="dpml-station-exec" basedir="exec">
<types>
<type id="jar"/>
- <part:plugin class="net.dpml.station.exec.ApplicationHandler"/>
+ <part:plugin class="net.dpml.station.exec.ApplicationHandler"
alias="true"/>
</types>
<dependencies scope="build">
<include ref="dpml/metro/dpml-metro-runtime"/>
@@ -53,9 +53,10 @@
</properties>
<types>
<type id="jar"/>
- <part:plugin class="net.dpml.station.server.StationServerPlugin"/>
+ <part:plugin class="net.dpml.station.server.StationServerPlugin"
alias="true"/>
</types>
<dependencies>
+ <include ref="dpml/depot/dpml-depot-console" tag="public"/>
<include ref="dpml/metro/dpml-metro-component" tag="public"/>
<include ref="dpml/transit/dpml-transit-main" tag="public"/>
<include ref="dpml/station/dpml-station-api" tag="public"/>

Modified: trunk/main/station/server/build.xml
===================================================================
--- trunk/main/station/server/build.xml 2006-03-26 23:37:07 UTC (rev 1270)
+++ trunk/main/station/server/build.xml 2006-03-27 07:28:04 UTC (rev 1271)
@@ -15,7 +15,6 @@
<include name="**/RemoteApplicationRegistry.class"/>
<include name="**/RemoteApplication.class"/>
<include name="**/RemoteStation.class"/>
- <include name="**/LoggingServer.class"/>
</rmic>
</target>


Modified:
trunk/main/station/server/src/main/net/dpml/station/server/LoggingServer.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/LoggingServer.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/station/server/src/main/net/dpml/station/server/LoggingServer.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -1,5 +1,5 @@
/*
- * Copyright 2005 Stephen McConnell.
+ * Copyright 2005-2006 Stephen McConnell.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,14 +18,23 @@

package net.dpml.station.server;

-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.util.logging.Logger;
import java.util.logging.LogRecord;
-import java.util.logging.Logger;
+import java.util.logging.Formatter;
+import java.util.logging.Level;

import net.dpml.lang.PID;
-import net.dpml.lang.LoggingService;

+import net.dpml.depot.LogStatement;
+
+import net.dpml.transit.util.ExceptionHelper;
+import net.dpml.transit.util.StandardFormatter;
+
/**
* The LoggingServer is a remote service that handles the aggregation of
* log records from multiple jvm processes.
@@ -33,36 +42,77 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class LoggingServer extends UnicastRemoteObject implements
LoggingService
+public class LoggingServer implements Runnable
{
- private final Logger m_logger = Logger.getLogger( "station" );
+ private static final PID PID = new PID();

+ private final ServerSocket m_server;
+
+ private int m_count = 0;
+
/**
* Creation of a new logging service instance.
* @exception RemoteException if a remote exception occurs
*/
- public LoggingServer() throws RemoteException
+ public LoggingServer( int port ) throws IOException
{
- super();
+ m_server = new ServerSocket( port );
}
-
+
/**
- * Dispach a log record to the server for processing. The implementation
- * prepends the log record message with the process id. Subsequent
processing
- * of log records is subject to the logging configuration applied to the
- * JVM process in which the server is established.
- *
- * @param process the process id of the jvm initiating the log record
- * @param record the log record
- * @exception RemoteException is a remote exception occurs
- */
- public void log( PID process, LogRecord record ) throws RemoteException
+ * Runnable implementation.
+ */
+ public void run()
{
- String raw = record.getMessage();
- int id = process.getValue();
- String message = "$[" + id + "] " + raw;
- record.setMessage( message );
- m_logger.log( record );
+ while( true )
+ {
+ try
+ {
+ Socket socket = m_server.accept();
+ InputStream input = socket.getInputStream();
+ ObjectInputStream stream = new ObjectInputStream( input );
+ Object object = stream.readObject();
+ if( object instanceof LogStatement )
+ {
+ LogStatement statement = (LogStatement) object;
+ PID pid = statement.getPID();
+ if( !PID.equals( pid ) )
+ {
+ int id = pid.getValue();
+ LogRecord record = statement.getLogRecord();
+ String raw = record.getMessage();
+ String message = "$[" + id + "] " + raw;
+ record.setMessage( message );
+ Logger logger = getNamedLogger( record );
+ logger.log( record );
+ }
+ }
+ input.close();
+ socket.close();
+ }
+ catch( Throwable e )
+ {
+ m_count++;
+ }
+ }
}
+
+ int getErrorCount()
+ {
+ return m_count;
+ }
+
+ private Logger getNamedLogger( LogRecord record )
+ {
+ String name = record.getLoggerName();
+ if( null != name )
+ {
+ return Logger.getLogger( name );
+ }
+ else
+ {
+ return Logger.getAnonymousLogger();
+ }
+ }
}


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-26 23:37:07 UTC (rev 1270)
+++
trunk/main/station/server/src/main/net/dpml/station/server/RemoteApplication.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -255,7 +255,6 @@
{
synchronized( m_state )
{
- setupLoggingDirectory();
setProcessState( ProcessState.STARTING );
try
{
@@ -348,12 +347,12 @@
//}
//

- //if( null == properties.getProperty(
"java.util.logging.config.class" ) )
- //{
- // properties.setProperty(
- // "java.util.logging.config.class",
- // "net.dpml.depot.DepotLoggingConfiguration" );
- //}
+ if( null == properties.getProperty( "java.util.logging.config.class"
) )
+ {
+ properties.setProperty(
+ "java.util.logging.config.class",
+ "net.dpml.depot.DepotLoggingConfiguration" );
+ }

properties.setProperty( "dpml.logging.config",
"local:properties:dpml/station/application" );

@@ -384,14 +383,6 @@
return (String[]) list.toArray( new String[0] );
}

- private void setupLoggingDirectory()
- {
- File logs = new File( Transit.DPML_DATA, "logs" );
- File station = new File( logs, "station" );
- File target = new File( station, m_id );
- target.mkdirs();
- }
-
/**
* Stop the application.
* @exception RemoteException if a rmote error occurs

Modified:
trunk/main/station/server/src/main/net/dpml/station/server/RemoteStation.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/RemoteStation.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/station/server/src/main/net/dpml/station/server/RemoteStation.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -42,11 +42,10 @@
import net.dpml.station.ApplicationRegistry;

import net.dpml.lang.Logger;
-import net.dpml.lang.LoggingService;
import net.dpml.lang.PID;
-import net.dpml.transit.Disposable;
import net.dpml.transit.monitor.LoggingAdapter;
import net.dpml.transit.model.TransitModel;
+import net.dpml.transit.Disposable;

import net.dpml.lang.UnknownKeyException;

@@ -57,16 +56,17 @@
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public class RemoteStation extends UnicastRemoteObject implements Station,
Manager, LoggingService
+public class RemoteStation extends UnicastRemoteObject implements Station,
Manager
{
- private final TransitModel m_model;
private final RemoteApplicationRegistry m_registry;
private final Map m_applications = new Hashtable();
private final Logger m_logger;
private final int m_port;
private final Registry m_rmiRegistry;
- private final LoggingServer m_loggingServer;
private final URL m_store;
+ private final TransitModel m_model;
+ private final LoggingServer m_server;
+ private final Thread m_thread;

private boolean m_terminated = false;

@@ -92,7 +92,6 @@
try
{
m_rmiRegistry.bind( STATION_KEY, this );
- getLogger().debug( "station bound to [" + STATION_KEY + "]" );
}
catch( AlreadyBoundException e )
{
@@ -100,20 +99,20 @@
"An instance of the Station is already bound to port " + port;
throw new StationException( error, e );
}
-
+
setShutdownHook( this );
startEventDispatchThread();

try
{
- m_loggingServer = new LoggingServer();
- m_rmiRegistry.bind( LoggingService.LOGGING_KEY, m_loggingServer
);
- getLogger().debug( "logging service bound to [" +
LoggingService.LOGGING_KEY + "]");
+ m_server = new LoggingServer( 2020 );
+ m_thread = new Thread( m_server );
+ m_thread.start();
}
- catch( AlreadyBoundException e )
+ catch( Exception e )
{
final String error =
- "An instance of the logging service is already bound to port "
+ port;
+ "Unexpected error while attempting to start the logging server
on port " + 2020;
throw new StationException( error, e );
}

@@ -238,28 +237,16 @@
{
// ignore
}
-
- if( m_model instanceof Disposable )
- {
- try
- {
- Disposable disposable = (Disposable) m_model;
- disposable.dispose();
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
-
try
{
- m_rmiRegistry.unbind( LoggingService.LOGGING_KEY );
+ getLogger().info( "issues: " + m_server.getErrorCount() );
+ m_thread.interrupt();
}
catch( Exception e )
{
// ignore
}
+
finally
{
if( getLogger().isInfoEnabled() )
@@ -269,6 +256,19 @@

if( exit )
{
+ if( m_model instanceof Disposable )
+ {
+ try
+ {
+ Disposable disposable = (Disposable) m_model;
+ disposable.dispose();
+ }
+ catch( Exception e )
+ {
+ // ignore
+ }
+ }
+
if( getLogger().isDebugEnabled() )
{
getLogger().debug( "terminating process" );
@@ -321,10 +321,10 @@
* @param record the log record
* @exception RemoteException is a remote exception occurs
*/
- public void log( PID process, LogRecord record ) throws RemoteException
- {
- m_loggingServer.log( process, record );
- }
+ //public void log( PID process, LogRecord record ) throws RemoteException
+ //{
+ // m_loggingServer.log( process, record );
+ //}


/**

Modified:
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
===================================================================
---
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
2006-03-26 23:37:07 UTC (rev 1270)
+++
trunk/main/station/server/src/main/net/dpml/station/server/StationServerPlugin.java
2006-03-27 07:28:04 UTC (rev 1271)
@@ -38,6 +38,7 @@

import net.dpml.transit.Artifact;
import net.dpml.transit.model.TransitModel;
+
import net.dpml.lang.Logger;

/**
@@ -59,12 +60,11 @@
/**
* Creation of a new station server plugin for station commandline
* handling.
- * @param model the transit model
* @param logger the assigned logging channel
* @param args the command line arguments array
* @exception Exception if an error occurs
*/
- public StationServerPlugin( TransitModel model, Logger logger, String[]
args ) throws Exception
+ public StationServerPlugin( Logger logger, TransitModel model, String[]
args ) throws Exception
{
m_logger = logger;
m_model = model;

Modified: trunk/main/transit/core/src/main/net/dpml/lang/PID.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/lang/PID.java 2006-03-26
23:37:07 UTC (rev 1270)
+++ trunk/main/transit/core/src/main/net/dpml/lang/PID.java 2006-03-27
07:28:04 UTC (rev 1271)
@@ -30,23 +30,22 @@
*/
public class PID implements Serializable
{
- private final int m_id;
+ private final int m_value;

/**
* Creation of a new process identifier.
*/
public PID()
{
- m_id = setupInitialValue();
+ m_value = setupInitialValue();
}

/**
* Creation of a new process identifier.
- * @param pid the process identity
*/
- public PID( int pid )
+ private PID( int id )
{
- m_id = pid;
+ m_value = id;
}

private static int setupInitialValue()
@@ -75,7 +74,7 @@
*/
public int getValue()
{
- return m_id;
+ return m_value;
}

/**
@@ -84,7 +83,7 @@
*/
public String toString()
{
- return "[" + m_id + "]";
+ return "[" + m_value + "]";
}

/**
@@ -94,15 +93,15 @@
*/
public boolean equals( Object other )
{
- if( other instanceof PID )
- {
- PID pid = (PID) other;
- return getValue() == pid.getValue();
- }
- else
- {
+ if( other instanceof PID )
+ {
+ PID pid = (PID) other;
+ return getValue() == pid.getValue();
+ }
+ else
+ {
return false;
- }
+ }
}

/**




  • r1271 - in trunk/main: depot depot/core depot/core/src/main/net/dpml/depot depot/tools/builder/src/main/net/dpml/tools/tasks metro/builder/src/main/net/dpml/metro/builder metro/component/src/main/net/dpml/component metro/model/src/main/net/dpml/metro/info metro/model/src/test/net/dpml/metro/data/test metro/model/src/test/net/dpml/metro/info/test metro/runtime/src/main/net/dpml/metro/runtime metro/tools/src/main/net/dpml/metro/tools planet/http/impl planet/http/server station station/server station/server/src/main/net/dpml/station/server transit/core/src/main/net/dpml/lang, mcconnell at BerliOS, 03/27/2006

Archive powered by MHonArc 2.6.24.

Top of Page