Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2236 - in development/main/metro/system: api/src/main/net/dpml/system impl/etc/main impl/src/main/net/dpml/system/impl test/src/test/net/dpml/system/impl/test

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell AT dpml.net
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2236 - in development/main/metro/system: api/src/main/net/dpml/system impl/etc/main impl/src/main/net/dpml/system/impl test/src/test/net/dpml/system/impl/test
  • Date: Thu, 07 Apr 2005 10:38:48 -0400

Author: mcconnell AT dpml.net
Date: Thu Apr 7 10:38:46 2005
New Revision: 2236

Added:
development/main/metro/system/impl/etc/main/dpml.system.properties
- copied, changed from r2234,
development/main/metro/system/impl/etc/main/system.properties
Removed:
development/main/metro/system/impl/etc/main/system.properties
Modified:

development/main/metro/system/api/src/main/net/dpml/system/SystemContext.java

development/main/metro/system/api/src/main/net/dpml/system/SystemCriteria.java

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContextFactory.java

development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemCriteria.java

development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties

development/main/metro/system/test/src/test/net/dpml/system/impl/test/SystemContextFactoryTestCase.java
Log:
Add declaration of the domain to the system context and fix an important bug
concerning property defaults resolution.

Modified:
development/main/metro/system/api/src/main/net/dpml/system/SystemContext.java
==============================================================================
---
development/main/metro/system/api/src/main/net/dpml/system/SystemContext.java
(original)
+++
development/main/metro/system/api/src/main/net/dpml/system/SystemContext.java
Thu Apr 7 10:38:46 2005
@@ -20,6 +20,7 @@

import java.io.File;
import java.util.Properties;
+import java.net.URI;

import net.dpml.context.Context;

@@ -52,6 +53,7 @@
static final String ANCHOR_KEY = GROUP + ".anchor";
static final String ISOLATE_KEY = GROUP + ".isolate";
static final String STRICT_KEY = GROUP + ".strict";
+ static final String DOMAIN_KEY = GROUP + ".domain";

static final String[] KEYS =
new String[]{
@@ -61,19 +63,28 @@
HOME_KEY,
TEMP_KEY,
ISOLATE_KEY,
- STRICT_KEY
+ STRICT_KEY,
+ DOMAIN_KEY
};

- /** Return the Info mode
- *
- */
+ /**
+ * Return the Info mode
+ *
+ */
boolean getInfoMode();

- /** Return the Debug mode
- *
- */
+ /**
+ * Return the Debug mode
+ *
+ */
boolean getDebugMode();

+ /**
+ * Return the the domain that this system context represents.
+ * @return the domain uri
+ */
+ URI getDomain();
+
/**
* Return the policy concerning the creation of implicit profiles. If
the value
* is FALSE then implicit profile creation is supported otherwise an
empty profile set

Modified:
development/main/metro/system/api/src/main/net/dpml/system/SystemCriteria.java
==============================================================================
---
development/main/metro/system/api/src/main/net/dpml/system/SystemCriteria.java
(original)
+++
development/main/metro/system/api/src/main/net/dpml/system/SystemCriteria.java
Thu Apr 7 10:38:46 2005
@@ -38,6 +38,12 @@
//--------------------------------------------------------------

/**
+ * Set the system domain uri.
+ * @param uri the domain identifying this system context.
+ */
+ void setDomain( URI name );
+
+ /**
* Set the isolation enabled.
* @param mode TRUE to enable isolation mode else FALSE
*/
@@ -121,4 +127,10 @@
*/
URI getLoggingURI();

+ /**
+ * Return the domain uri.
+ * @return the domain name.
+ */
+ URI getDomain();
+
}

Copied: development/main/metro/system/impl/etc/main/dpml.system.properties
(from r2234, development/main/metro/system/impl/etc/main/system.properties)
==============================================================================
--- development/main/metro/system/impl/etc/main/system.properties
(original)
+++ development/main/metro/system/impl/etc/main/dpml.system.properties Thu
Apr 7 10:38:46 2005
@@ -6,6 +6,7 @@
# the system context criteria creation phase.
#

+dpml.system.domain = system:dpml/local
dpml.system.logging.artifact = @DEFAULT-LOGGING-PLUGIN-SPEC@
dpml.system.anchor = ${dpml.home}/lib


Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
Thu Apr 7 10:38:46 2005
@@ -19,7 +19,7 @@
package net.dpml.system.impl;

import java.io.File;
-
+import java.net.URI;
import java.util.Properties;

import net.dpml.context.impl.DefaultContext;
@@ -62,6 +62,7 @@
private final boolean m_isolate;
private final String[] m_remainder;
private final Properties m_properties;
+ private final URI m_domain;

//
------------------------------------------------------------------------
// constructors
@@ -71,7 +72,7 @@
final Repository repository, final LoggingManager logging,
final Logger logger, final File home, final File work, final File
anchor, final File temp,
final boolean info, final boolean debug, final boolean isolate, final
boolean strict,
- String[] remainder, Properties properties )
+ String[] remainder, Properties properties, URI domain )
throws NullArgumentException
{
super();
@@ -83,6 +84,7 @@
assertNotNull( "anchor", anchor );
assertNotNull( "temp", temp );
assertNotNull( "properties", properties );
+ assertNotNull( "domain", domain );

logger.debug( "system context initialization" );

@@ -99,6 +101,7 @@
m_remainder = remainder;
m_properties = properties;
m_strict = strict;
+ m_domain = domain;

}

@@ -106,6 +109,11 @@
// SystemContext
//
------------------------------------------------------------------------

+ public URI getDomain()
+ {
+ return m_domain;
+ }
+
public boolean getInfoMode()
{
return m_info;

Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContextFactory.java
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContextFactory.java
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContextFactory.java
Thu Apr 7 10:38:46 2005
@@ -112,35 +112,6 @@
// constructors
//
------------------------------------------------------------------------

- private boolean resolveDebugMode( Map map )
- {
- Object object = map.get( "urn:transit.debug.policy" );
- if( null == object )
- {
- return false;
- }
- else
- {
- if( object instanceof Boolean )
- {
- Boolean debug = (Boolean) object;
- return debug.booleanValue();
- }
- else if( object instanceof String )
- {
- Boolean debug = new Boolean( (String) object );
- return debug.booleanValue();
- }
- else
- {
- final String error =
- "Unrecognized boolean argument class ["
- + object.getClass().getName();
- throw new IllegalStateException( error );
- }
- }
- }
-
public DefaultSystemContextFactory(
Map map, Repository repository, String[] args )
throws Exception
@@ -170,7 +141,7 @@
props.put( Transit.HOME_KEY, m_home.toString() );
m_properties = getStaticProperties( m_home, SystemContext.DOMAIN,
DefaultSystemContextFactory.class.getClassLoader(),
- "/system.properties" );
+ "dpml.system.properties" );

// TODO: the expansion below seems to be very basic, and should
be replaced by the
// net.dpml.transit.artifact.PropertyResolver class.
@@ -225,16 +196,20 @@

try
{
+ if( m_line.hasOption( "domain" ) )
+ {
+ String name = m_line.getOptionValue( "domain" );
+ criteria.put( SystemContext.DOMAIN_KEY, name );
+ }
+
if( m_line.hasOption( "noproxy" ) )
{
criteria.setIsolationMode( false );
}
-
else if( m_line.hasOption( "proxy" ) )
{
criteria.setIsolationMode( true );
}
-
else if( m_line.hasOption( "strict" ) )
{
criteria.setStrictProfileCreationPolicy( true );
@@ -257,6 +232,7 @@
String path = m_line.getOptionValue( "logging" );
criteria.put( SystemContext.LOGGING_CONFIGURATION_KEY, path
);
}
+
}
catch( Throwable e )
{
@@ -305,7 +281,9 @@
URI uri = criteria.getLoggingURI();
LoggingManager logging =
createLoggingManager( m_repository, uri, dir, url, m_DebugMode );
- Logger logger = logging.getLoggerForCategory( SystemContext.DOMAIN );
+ URI domain = criteria.getDomain();
+ String path = domain.getSchemeSpecificPart();
+ Logger logger = logging.getLoggerForCategory( path );
Repository repository = createRepository();
boolean strict = criteria.getStrictProfileCreationPolicy();

@@ -332,6 +310,7 @@
new StringBuffer( "System Context" );
buffer.append( SystemContext.LINE );

+ pack( buffer, SystemContext.DOMAIN_KEY, domain );
pack( buffer, SystemContext.LOGGING_IMPLEMENTATION_KEY, uri );
pack( buffer, SystemContext.LOGGING_CONFIGURATION_KEY, url );
pack( buffer, SystemContext.HOME_KEY, Transit.DPML_HOME );
@@ -351,7 +330,7 @@

return new DefaultSystemContext(
repository, logging, logger, Transit.DPML_HOME, dir, anchor,
temp,
- m_InfoMode, m_DebugMode, isolate, strict, m_remainder,
m_properties );
+ m_InfoMode, m_DebugMode, isolate, strict, m_remainder,
m_properties, domain );
}

private void setupMonitors( Logger logger ) throws SystemException
@@ -557,6 +536,36 @@
throw new NullArgumentException( key );
}

+
+ private boolean resolveDebugMode( Map map )
+ {
+ Object object = map.get( "urn:transit.debug.policy" );
+ if( null == object )
+ {
+ return false;
+ }
+ else
+ {
+ if( object instanceof Boolean )
+ {
+ Boolean debug = (Boolean) object;
+ return debug.booleanValue();
+ }
+ else if( object instanceof String )
+ {
+ Boolean debug = new Boolean( (String) object );
+ return debug.booleanValue();
+ }
+ else
+ {
+ final String error =
+ "Unrecognized boolean argument class ["
+ + object.getClass().getName();
+ throw new IllegalStateException( error );
+ }
+ }
+ }
+
private Options buildCommandLineOptions()
{
Options options = new Options();
@@ -616,6 +625,10 @@
.withDescription( REZ.getString( "cli-hosts-description" ) )
.withValueSeparator( ',' )
.create( "hosts" ) );
+ options.addOption(
+ OptionBuilder.hasArg().withArgName( REZ.getString( "uri" ) )
+ .withDescription( REZ.getString( "cli-domain-description" ) )
+ .create( "domain" ) );

return options;
}
@@ -624,13 +637,13 @@
ClassLoader cl, String
bootstrap )
throws IOException
{
- String filename = key + ".properties";
+ Properties properties = getStaticProperties( cl, bootstrap );

//
// get [home]/[key].properties
//

- Properties properties = getStaticProperties( cl, bootstrap );
+ String filename = key + ".properties";
File homePreferenceFile = new File( home, filename );
loadFile( properties, homePreferenceFile );

@@ -703,6 +716,5 @@
}
}
}
-
}


Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemCriteria.java
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemCriteria.java
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemCriteria.java
Thu Apr 7 10:38:46 2005
@@ -61,7 +61,8 @@
SystemContext.DIR_KEY,
SystemContext.ANCHOR_KEY,
SystemContext.ISOLATE_KEY,
- SystemContext.STRICT_KEY
+ SystemContext.STRICT_KEY,
+ SystemContext.DOMAIN_KEY
};

/**
@@ -72,6 +73,12 @@
{
return new Parameter[] {
new Parameter(
+ SystemContext.DOMAIN_KEY,
+ URI.class,
+ getDefaultURI(
+ properties.getProperty( SystemContext.DOMAIN_KEY ) )
+ ),
+ new Parameter(
SystemContext.LOGGING_IMPLEMENTATION_KEY,
URI.class,
getDefaultURI(
@@ -254,6 +261,20 @@
}

/**
+ * Set the system domain name.
+ * @param domain the identifying domain
+ */
+ public void setDomain( URI uri )
+ throws NullArgumentException
+ {
+ if( null == uri )
+ {
+ throw new NullArgumentException( SystemContext.DOMAIN_KEY );
+ }
+ put( SystemContext.DOMAIN_KEY, uri );
+ }
+
+ /**
* Set the logging system artifact specification.
* @param uri the URI of the logging system artifact spec
*/
@@ -272,6 +293,27 @@
//----------------------------------------------------------------

/**
+ * Get the system domain name.
+ * @return the domain name
+ */
+ public URI getDomain()
+ {
+ URI uri = getURIValue( SystemContext.DOMAIN_KEY );
+ if( null == uri )
+ {
+ final String error =
+ "Internal error - the uri default for the key '"
+ + SystemContext.DOMAIN_KEY
+ + "' returned a null value.";
+ throw new IllegalStateException( error );
+ }
+ else
+ {
+ return uri;
+ }
+ }
+
+ /**
* Get the isolation enabled policy
* @return mode TRUE if isolation mode enabled else FALSE
*/
@@ -402,10 +444,28 @@
*/
public URI getLoggingURI()
{
- Object object = get( SystemContext.LOGGING_IMPLEMENTATION_KEY );
+ URI uri = getURIValue( SystemContext.LOGGING_IMPLEMENTATION_KEY );
+ if( null == uri )
+ {
+ uri = convertToURI( DEFAULT_LOGGING_PLUGIN_SPEC );
+ }
+ return uri;
+ }
+
+ //----------------------------------------------------------------
+ // internals
+ //----------------------------------------------------------------
+
+ /**
+ * Get a uri value.
+ * @return the uri value
+ */
+ private URI getURIValue( String key )
+ {
+ Object object = get( key );
if( null == object )
{
- return convertToURI( DEFAULT_LOGGING_PLUGIN_SPEC );
+ return null;
}
else if( object instanceof URI )
{
@@ -426,9 +486,23 @@
}
}

- //----------------------------------------------------------------
- // internals
- //----------------------------------------------------------------
+ private String getStringValue( String key )
+ throws NullArgumentException
+ {
+ Object object = get( key );
+ if( null == object )
+ {
+ throw new NullArgumentException( key );
+ }
+ if( object instanceof String )
+ {
+ return (String) object;
+ }
+ else
+ {
+ return object.toString();
+ }
+ }

private boolean getBooleanValue( String key )
throws NullArgumentException

Modified:
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
==============================================================================
---
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
(original)
+++
development/main/metro/system/impl/src/main/net/dpml/system/impl/Resources.properties
Thu Apr 7 10:38:46 2005
@@ -31,3 +31,4 @@

cli-cache-description=An absolute or relative path to a cache directory.
cli-hosts-description=A comma separated sequence of remote host urls.
+cli-domain-description=The system domain uri.

Modified:
development/main/metro/system/test/src/test/net/dpml/system/impl/test/SystemContextFactoryTestCase.java
==============================================================================
---
development/main/metro/system/test/src/test/net/dpml/system/impl/test/SystemContextFactoryTestCase.java
(original)
+++
development/main/metro/system/test/src/test/net/dpml/system/impl/test/SystemContextFactoryTestCase.java
Thu Apr 7 10:38:46 2005
@@ -67,6 +67,7 @@
assertNotNull( "temp", m_context.getTempDirectory() );
assertNotNull( "logging", m_context.getLoggingManager() );
assertNotNull( "repository", m_context.getRepository() );
+ assertNotNull( "domain", m_context.getDomain() );
}

}



  • svn commit: r2236 - in development/main/metro/system: api/src/main/net/dpml/system impl/etc/main impl/src/main/net/dpml/system/impl test/src/test/net/dpml/system/impl/test, mcconnell, 04/06/2005

Archive powered by MHonArc 2.6.24.

Top of Page