Skip to Content.
Sympa Menu

notify-dpml - svn commit: r2894 - in development/laboratory/users/niclas/osgi/metro: activation/impl/src/main/net/dpml/activation/impl activation/providers/metro/src/main/net/dpml/activation/metro composition/impl/src/main/net/dpml/composition/model/impl logging/providers meta/impl/src/main/net/dpml/meta/info/builder/impl system/impl/src/main/net/dpml/system/impl system/spi/src/main/net/dpml/system

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: niclas AT hedhman.org
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: svn commit: r2894 - in development/laboratory/users/niclas/osgi/metro: activation/impl/src/main/net/dpml/activation/impl activation/providers/metro/src/main/net/dpml/activation/metro composition/impl/src/main/net/dpml/composition/model/impl logging/providers meta/impl/src/main/net/dpml/meta/info/builder/impl system/impl/src/main/net/dpml/system/impl system/spi/src/main/net/dpml/system
  • Date: Mon, 20 Jun 2005 03:59:00 -0400

Author: niclas AT hedhman.org
Date: Mon Jun 20 03:59:00 2005
New Revision: 2894

Removed:
development/laboratory/users/niclas/osgi/metro/logging/providers/
Modified:

development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java

development/laboratory/users/niclas/osgi/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java

development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java

development/laboratory/users/niclas/osgi/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/ServiceBuilder.java

development/laboratory/users/niclas/osgi/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java

development/laboratory/users/niclas/osgi/metro/system/spi/src/main/net/dpml/system/SystemContext.java
Log:
Some more formatting and removal of unused methods.

Modified:
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/impl/src/main/net/dpml/activation/impl/DefaultRuntime.java
Mon Jun 20 03:59:00 2005
@@ -47,8 +47,7 @@
// static
//--------------------------------------------------------------

- private static final String METRO_RUNTIME =
- "@METRO-RUNTIME-PROVIDER-SPEC@";
+ private static final String METRO_RUNTIME =
"@METRO-RUNTIME-PROVIDER-SPEC@";

//--------------------------------------------------------------
// immutable state

Modified:
development/laboratory/users/niclas/osgi/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/activation/providers/metro/src/main/net/dpml/activation/metro/DefaultRuntimeFactory.java
Mon Jun 20 03:59:00 2005
@@ -34,11 +34,11 @@
import java.util.Map;

/**
- * A factory enabling the establishment of runtime handlers.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
+* A factory enabling the establishment of runtime handlers.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
public class DefaultRuntimeFactory implements RuntimeFactory
{
//-------------------------------------------------------------------
@@ -75,7 +75,7 @@
// RuntimeFactory
//-------------------------------------------------------------------

- /**
+ /**
* Resolve a runtime handler for a model.
* @param model the deployment model
* @return the runtime appliance
@@ -105,14 +105,10 @@
}
else
{
- final String error =
- REZ.getString(
- "runtime.error.unknown-model",
- model.toString(),
- model.getClass().getName() );
- throw new ModelRuntimeException( error );
+ String classname = model.getClass().getName();
+ final String error = REZ.getString(
"runtime.error.unknown-model", model.toString(), classname );
+ throw new ModelRuntimeException( error );
}
-
registerRuntime( model, runtime );
return runtime;
}
@@ -122,7 +118,7 @@
// private implementation
//-------------------------------------------------------------------

- /**
+ /**
* Resolve a runtime handler for a component model.
* @param model the containment model
* @return the runtime handler

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultClassLoaderModel.java
Mon Jun 20 03:59:00 2005
@@ -150,9 +150,7 @@
ArrayList services = new ArrayList();
Logger scannerLogger = getLocalLogger().getChildLogger(
"scanner" );
SystemContext system = context.getSystemContext();
-
Scanner scanner = new Scanner( scannerLogger, system,
m_classLoader );
-
scanner.scan( m_urls, types, services );

//
@@ -276,12 +274,9 @@
private ClassLoaderContext createChildContext( Logger logger,
ContainmentProfile profile, URL[] implied )
{
SystemContext system = m_context.getSystemContext();
- ClassLoaderDirective directive =
- profile.getClassLoaderDirective();
+ ClassLoaderDirective directive = profile.getClassLoaderDirective();

- return new DefaultClassLoaderContext(
- logger, system, m_classLoader,
- m_types, m_services, directive, implied );
+ return new DefaultClassLoaderContext( logger, system, m_classLoader,
m_types, m_services, directive, implied );
}

private String[] getClassPath()

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModel.java
Mon Jun 20 03:59:00 2005
@@ -945,8 +945,7 @@
if( getLogger().isDebugEnabled() )
{
SystemContext system = m_context.getSystemContext();
- final String message =
- REZ.getString( "containment.add", system.toString( name ) );
+ final String message = REZ.getString( "containment.add",
system.toString( name ) );
getLogger().debug( message );
}


Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/DefaultContainmentModelComponentHelper.java
Mon Jun 20 03:59:00 2005
@@ -115,25 +115,10 @@
try
{
Class base = classloader.loadClass( profile.getClassname() );
- Type type =
- m_model.getClassLoaderModel().getTypeRepository().getType(
base );
-
- return new DefaultComponentContext(
- logger,
- name,
- system,
- classloader,
- graph,
- m_model,
- profile,
- type,
- base,
- dir,
- temp,
- partition,
- m_context.getRuntime(),
- m_context.getDefaultDeploymentTimeout() );
+ Type type =
m_model.getClassLoaderModel().getTypeRepository().getType( base );

+ return new DefaultComponentContext( logger, name, system,
classloader, graph, m_model,
+ profile, type, base, dir, temp, partition,
m_context.getRuntime(), m_context.getDefaultDeploymentTimeout() );
}
catch( ClassNotFoundException e )
{

Modified:
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/composition/impl/src/main/net/dpml/composition/model/impl/Scanner.java
Mon Jun 20 03:59:00 2005
@@ -18,7 +18,6 @@

package net.dpml.composition.model.impl;

-import net.dpml.composition.data.builder.ProfilePackageBuilder;
import net.dpml.composition.model.ModelException;
import net.dpml.exception.ExceptionHelper;
import net.dpml.i18n.ResourceManager;
@@ -26,18 +25,18 @@
import net.dpml.lang.NullArgumentException;
import net.dpml.logging.Logger;
import net.dpml.meta.info.Service;
-import net.dpml.meta.info.ServiceDescriptor;
import net.dpml.meta.info.Type;
+import net.dpml.meta.info.builder.BuildException;
import net.dpml.meta.info.builder.impl.ServiceBuilder;
import net.dpml.meta.info.builder.impl.TypeBuilder;
import net.dpml.system.SystemContext;

import java.io.File;
+import java.io.IOException;
import java.io.InputStream;
import java.net.JarURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
-import java.util.ArrayList;
import java.util.Enumeration;
import java.util.List;
import java.util.jar.JarFile;
@@ -45,55 +44,44 @@
import java.util.zip.ZipEntry;

/**
- * A repository for services, types and profiles.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
+* A repository for services, types and profiles.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
class Scanner
{
//==============================================================
// static
//==============================================================

- private static final Resources REZ =
- ResourceManager.getPackageResources( Scanner.class );
+ private static final Resources REZ =
ResourceManager.getPackageResources( Scanner.class );

private static final String X_INFO = ".xinfo";
- private static final String X_TYPE = ".xtype";
private static final String X_SERVICE = ".xservice";
- private static final String X_PROFILE = ".xprofile";

/**
- * The type builder.
- */
- private static final TypeBuilder TYPE_BUILDER =
- new TypeBuilder();
+ * The type builder.
+ */
+ private static final TypeBuilder TYPE_BUILDER = new TypeBuilder();

/**
- * The service builder.
- */
- private static final ServiceBuilder SERVICE_BUILDER =
- new ServiceBuilder();
-
- /**
- * The packaged profile builder.
- */
- private static final ProfilePackageBuilder PACKAGE_BUILDER =
- new ProfilePackageBuilder();
+ * The service builder.
+ */
+ private static final ServiceBuilder SERVICE_BUILDER = new
ServiceBuilder();

//===================================================================
// state
//===================================================================

/**
- * Parent repository.
- */
+ * Parent repository.
+ */
private ClassLoader m_classloader;

/**
- * System context.
- */
+ * System context.
+ */
private SystemContext m_system;

private Logger m_logger;
@@ -104,15 +92,15 @@
//===================================================================

/**
- * Creation of a new scanner using a supplied classloader.
- * The scanner is responsible for scanning suppied URLs for
- * service and types.
- *
- * @param logger the logging channel
- * @param classloader the classloader
- * @exception NullArgumentException if the classloader argument or the
system
- * argument is null.
- */
+ * Creation of a new scanner using a supplied classloader.
+ * The scanner is responsible for scanning suppied URLs for
+ * service and types.
+ *
+ * @param logger the logging channel
+ * @param classloader the classloader
+ * @exception NullArgumentException if the classloader argument or the
system
+ * argument is null.
+ */
public Scanner( Logger logger, SystemContext system, ClassLoader
classloader )
throws NullArgumentException
{
@@ -134,61 +122,75 @@
//=======================================================================

/**
- * Scan the supplied url for Service and Type defintions.
- * @param urls the URL array to scan
- * @param types the map to populate with types as keys and
- * and packaged profiles as values
- * @param services a list to be populated with service descriptors
- */
- public void scan( URL[] urls, List types, List services ) throws
ModelException
+ * Scan the supplied url for Service and Type defintions.
+ * @param urls the URL array to scan
+ * @param types the map to populate with types as keys and
+ * and packaged profiles as values
+ * @param services a list to be populated with service descriptors
+ */
+ public void scan( URL[] urls, List types, List services )
+ throws ModelException, IOException
{
for( int i=0; i<urls.length; i++ )
{
- scanURL( urls[i], types, services );
+ try
+ {
+ scanURL( urls[i], types, services );
+ } catch( IOException e )
+ {
+ String message = "Unable to scan " + urls[ i ] + " for " +
types + " and " + services + " due to " + e;
+ getLogger().error( ExceptionHelper.packException( message,
e, getLogger().isDebugEnabled() ) );
+ } catch( ModelException e )
+ {
+ String message = "Unable to scan " + urls[ i ] + " for " +
types + " and " + services + " due to " + e;
+ getLogger().error( ExceptionHelper.packException( message,
e, getLogger().isDebugEnabled() ) );
+ }
}
}

/**
- * Add a URL to the classpath.
- * @param url the URL to add to the repository
- */
- private void scanURL( URL url, List types, List services ) throws
ModelException
+ * Add a URL to the classpath.
+ * @param url the URL to add to the repository
+ */
+ private void scanURL( URL url, List types, List services )
+ throws ModelException, IOException
{
if( getLogger().isDebugEnabled() )
{
- final String message =
- REZ.getString(
- "scanner.scanning",
- m_system.toString( url.toString() ) );
+ String message = REZ.getString( "scanner.scanning",
m_system.toString( url.toString() ) );
getLogger().debug( message );
}
if( isDirectory( url ) )
{
scanDirectory( url, types, services );
}
- else if(
- url.getProtocol().equals( "jar" )
- || ( url.getProtocol().equals( "file" ) &&
url.toString().endsWith( ".jar" ) ) )
- {
- scanJarFileURL( url, types, services );
- }
else
{
- scanInputStream( url, types, services );
+ boolean isJarProtocol = "jar".equals( url.getProtocol() );
+ boolean isFileProtocol = "file".equals( url.getProtocol() );
+ boolean isJarFile = url.toString().endsWith( ".jar" );
+ if( isJarProtocol || ( isFileProtocol && isJarFile ) )
+ {
+ scanJarFileURL( url, types, services );
+ }
+ else
+ {
+ scanInputStream( url, types, services );
+ }
}
}

- private void scanDirectory( URL url, List types, List services ) throws
ModelException
+ private void scanDirectory( URL url, List types, List services )
+ throws ModelException, IOException
{
try
{
File directory = getDirectory( url );
scanDirectoryContent( directory, directory, types, services );
}
- catch( Throwable e )
+ catch( IllegalArgumentException e )
{
- final String error =
- REZ.getString( "scanner.dir-scan.error", url.toString() );
+ String error = REZ.getString( "scanner.dir-scan.error",
url.toString() );
throw new ModelException( error, e );
}
}
@@ -198,41 +200,43 @@
URL uri = url;
try
{
- if( !url.getProtocol().equals( "jar" ) )
+ boolean isNotJarProtocol = "jar".equals( url.getProtocol() ) ==
false;
+ if( isNotJarProtocol )
{
uri = getJarURL( url );
}
-
- if( !uri.toString().endsWith( "!/" ) )
+ boolean doesNotContainsPart = uri.toString().endsWith( "!/" ) ==
false;
+ if( doesNotContainsPart )
{
- final String error =
- REZ.getString(
- "scanner.nested-jar-unsupported.error",
- url.toString() );
+ String error = REZ.getString(
"scanner.nested-jar-unsupported.error", url.toString() );
throw new ModelException( error );
}

- final JarURLConnection jar = (JarURLConnection)
uri.openConnection();
- final JarFile base = jar.getJarFile();
+ JarURLConnection jar = (JarURLConnection) uri.openConnection();
+ JarFile base = jar.getJarFile();
scanJarFile( base, types, services );
}
- catch( Throwable e )
+ catch( MalformedURLException e )
{
- final String error =
- REZ.getString( "scanner.jar.error", url.toString() );
+ String error = REZ.getString( "scanner.jar.error",
url.toString() );
+ throw new ModelException( error, e );
+ }
+ catch( IOException e )
+ {
+ String error = REZ.getString( "scanner.jar.error",
url.toString() );
throw new ModelException( error, e );
}
}

- private void scanJarFile( JarFile base, List types, List services )
throws Exception
+ private void scanJarFile( JarFile base, List types, List services )
+ throws ModelException
{
- long start = System.currentTimeMillis();
Enumeration entries = base.entries();
while( entries.hasMoreElements() )
{
ZipEntry entry = (ZipEntry) entries.nextElement();
String name = entry.getName();
- if( name.endsWith( X_TYPE ) || name.endsWith( X_INFO ) )
+ if( name.endsWith( X_INFO ) )
{
addType( types, name );
}
@@ -244,6 +248,7 @@
}

private void scanInputStream( URL url, List types, List services )
+ throws ModelException
{
try
{
@@ -258,37 +263,31 @@
{
if( getLogger().isWarnEnabled() )
{
- final String warning =
- REZ.getString(
- "scanner.stream.unrecognized-content.warning",
- url.toString() );
+ String warning = REZ.getString(
"scanner.stream.unrecognized-content.warning", url.toString() );
getLogger().warn( warning );
}
}
}
- catch( Throwable e )
+ catch( IOException e )
{
if( getLogger().isWarnEnabled() )
{
- final String error =
- REZ.getString(
- "scanner.stream.content.error",
- url.toString() );
- final String warning = ExceptionHelper.packException(
- error, e, getLogger().isDebugEnabled() );
+ String error = REZ.getString(
"scanner.stream.content.error", url.toString() );
+ String warning = ExceptionHelper.packException( error, e,
getLogger().isDebugEnabled() );
getLogger().warn( warning );
}
}
}

- private void scanJarInputStream( JarInputStream stream, List types, List
services ) throws Exception
+ private void scanJarInputStream( JarInputStream stream, List types, List
services )
+ throws ModelException
{
ZipEntry entry = null;
try
{
entry = stream.getNextEntry();
}
- catch( Throwable e )
+ catch( IOException e )
{
entry = null;
}
@@ -296,7 +295,7 @@
while( entry != null )
{
String name = entry.getName();
- if( name.endsWith( X_TYPE ) || name.endsWith( X_INFO ) )
+ if( name.endsWith( X_INFO ) )
{
addType( types, name );
}
@@ -309,14 +308,15 @@
{
entry = stream.getNextEntry();
}
- catch( Throwable e )
+ catch( IOException e )
{
entry = null;
}
}
}

- private void scanDirectoryContent( File base, File dir, List types, List
services ) throws Exception
+ private void scanDirectoryContent( File base, File dir, List types, List
services )
+ throws IOException, ModelException
{
File[] files = dir.listFiles();
String path = base.toString();
@@ -335,275 +335,143 @@
}
}

- private void scanFile( int j, File file, List types, List services )
throws Exception
+ private void scanFile( int j, File file, List types, List services )
+ throws ModelException
{
String filename = file.toString();
String name = filename.substring( j, filename.length() );
- if( name.endsWith( X_TYPE ) || name.endsWith( X_INFO ) )
+ boolean isXInfo = name.endsWith( X_INFO );
+ boolean isXService = name.endsWith( X_SERVICE );
+ if( isXInfo )
{
addType( types, name );
}
- else if( name.endsWith( X_SERVICE ) )
+ else if( isXService )
{
addService( services, name );
}
}

- private void addType( List types, String name ) throws Exception
+ private void addType( List types, String name )
+ throws ModelException
{
String classname = parseResourceName( name );
Class clazz = getComponentClass( classname );
- Type type = TYPE_BUILDER.buildType( clazz );
try
{
- verifyType( type, clazz );
+ Type type = TYPE_BUILDER.buildType( clazz );
if( getLogger().isDebugEnabled() )
{
- final String message =
- REZ.getString( "scanner.type.addition", classname );
+ String message = REZ.getString( "scanner.type.addition",
classname );
getLogger().debug( message );
}
types.add( type );
}
- catch( NoClassDefFoundError e )
+ catch( Exception e )
{
if( getLogger().isWarnEnabled() )
{
- final String error =
- REZ.getString(
- "scanner.type.verification.ncdf.failure",
- classname, e.getMessage() );
- getLogger().warn( error );
- }
- }
- catch( Throwable e )
- {
- if( getLogger().isWarnEnabled() )
- {
- final String error =
- REZ.getString(
- "scanner.type.verification.failure",
- classname );
- getLogger().warn( ExceptionHelper.packException(
- error, e, getLogger().isDebugEnabled() ) );
+ String error = REZ.getString(
"scanner.type.verification.failure", classname );
+ getLogger().warn( ExceptionHelper.packException( error, e,
getLogger().isDebugEnabled() ) );
}
}
}

- private void addService( List list, String name ) throws Exception
+ private void addService( List list, String name )
+ throws ModelException
{
String classname = parseResourceName( name );
- Service service =
- SERVICE_BUILDER.build( classname, m_classloader );
try
{
+ Service service = SERVICE_BUILDER.build( classname,
m_classloader );
verifyService( service );
if( getLogger().isDebugEnabled() )
{
- final String message =
- REZ.getString(
- "scanner.service.addition",
- classname );
+ String message = REZ.getString( "scanner.service.addition",
classname );
getLogger().debug( message );
}
list.add( service );
}
- catch( Throwable e )
+ catch( BuildException e )
{
if( getLogger().isWarnEnabled() )
{
- final String error =
- REZ.getString(
- "scanner.service.verification.failure",
- classname );
- getLogger().warn( ExceptionHelper.packException(
- error, e, getLogger().isDebugEnabled() ) );
+ String error = REZ.getString(
"scanner.service.verification.failure", classname );
+ getLogger().warn( ExceptionHelper.packException( error, e,
getLogger().isDebugEnabled() ) );
}
}
}

/**
- * Verify the intergrity of the supplied type.
- * @param type the type to verify
- * @param clazz the implementation class
- * @exception Exception if an verification failure occurs
- */
- private void verifyType( Type type, Class clazz ) throws Exception
- {
- final String name = type.getInfo().getName();
- final Class[] classes = getServiceClasses( type );
- //final TypeVerifier verifier = new TypeVerifier(); // <-- FIX ME
- //verifier.verifyType( name, clazz, classes );
- }
-
- /**
- * Verify the intergrity of the supplied type.
- * @param service the service to be verified.
- * @exception Exception if an verification failure occurs
- */
- private void verifyService( Service service ) throws Exception
+ * Verify the intergrity of the supplied type.
+ * @param service the service to be verified.
+ * @exception ModelException if an verification failure occurs
+ */
+ private void verifyService( Service service )
+ throws ModelException
{
String classname = service.getClassname();
try
{
m_classloader.loadClass( classname );
}
- catch( NoClassDefFoundError ncdf )
- {
- String ref = parseResourceName( ncdf.getMessage() );
- final String error =
- REZ.getString(
- "scanner.service.bad-class.error",
- classname, ref );
- throw new ModelException( error );
- }
catch( ClassNotFoundException cnfe )
{
- final String error =
- REZ.getString(
- "scanner.service.missing-class.error",
- classname );
+ String error = REZ.getString(
"scanner.service.missing-class.error", classname );
throw new ModelException( error );
}
}

/**
- * Return the set of interface classes for a given type that are declared
- * or default to the service access protocol and where the
- * service access model is undefined.
- *
- * @param type the component type
- * @return an array of classes represnting the type's service interfaces
- */
- private Class[] getServiceClasses( Type type )
- throws ModelException
- {
- ArrayList list = new ArrayList();
- ServiceDescriptor[] services = type.getServices();
- for( int i = 0; i < services.length; i++ )
- {
- ServiceDescriptor service = services[i];
- String serviceAccess = service.getAttribute(
"urn:metro:service.accessor", null );
- if( serviceAccess == null )
- {
- list.add( getServiceClass( services[i] ) );
- }
- }
- return (Class[]) list.toArray( new Class[0] );
- }
-
- /**
- * Returns the component type implementation class.
- * @param type the component type descriptor
- * @return the class implementing the component type
- * @exception ModelException if a classloader error occurs
- * @exception NullArgumentException if the type argument is null.
- */
- private Class getComponentClass( Type type )
- throws ModelException, NullArgumentException
- {
- if( null == type )
- {
- throw new NullArgumentException( "type" );
- }
- return getComponentClass( type.getInfo().getClassname() );
- }
-
- /**
- * Returns the component type implementation class.
- * @param classname the component type implementation classname
- * @exception ModelException if a classloader error occurs
- */
+ * Returns the component type implementation class.
+ * @param classname the component type implementation classname
+ * @exception ModelException if a classloader error occurs
+ */
private Class getComponentClass( String classname )
- throws ModelException
+ throws ModelException
{
try
{
return m_classloader.loadClass( classname );
}
- catch( NoClassDefFoundError ncdf )
- {
- String ref = parseResourceName( ncdf.getMessage() );
- final String error =
- REZ.getString(
- "scanner.type.bad-class.error",
- classname, ref );
- getLogger().error( error );
- //getLogger().error( "CLASSLOADER:\n" + m_classloader );
- throw new ModelException( error );
- }
catch( ClassNotFoundException cnfe )
{
- final String error =
- REZ.getString(
- "scanner.type.missing-class.error", classname );
- throw new ModelException( error );
- }
- }
-
- /**
- * Returns the service type implementation class.
- * @param service the service type descriptor
- * @return the class implementing the service type
- * @exception ModelException if a classloader error occurs
- */
- private Class getServiceClass( ServiceDescriptor service ) throws
ModelException
- {
- final String classname = service.getReference().getClassname();
- try
- {
- return m_classloader.loadClass( classname );
- }
- catch( NoClassDefFoundError ncdf )
- {
- String ref = parseResourceName( ncdf.getMessage() );
- final String error =
- REZ.getString(
- "scanner.service.bad-class.error", classname, ref );
- throw new ModelException( error );
- }
- catch( ClassNotFoundException cnfe )
- {
- final String error =
- REZ.getString(
- "scanner.service.missing-class.error", classname );
+ String error = REZ.getString(
"scanner.type.missing-class.error", classname );
throw new ModelException( error );
}
}

private boolean isDirectory( URL url )
{
- if( url.getProtocol().equals( "file" ) )
+ boolean isFileProtocol = "file".equals( url.getProtocol() );
+ if( isFileProtocol )
{
return getFile( url ).isDirectory();
}
return false;
}

- private File getDirectory( URL url ) throws IllegalArgumentException
+ private File getDirectory( URL url )
+ throws IllegalArgumentException
{
File file = getFile( url );
if( file.isDirectory() )
{
return file;
}
- final String error =
- REZ.getString(
- "scanner.url-not-a-directory.error",
- url.toString() );
+ String error = REZ.getString( "scanner.url-not-a-directory.error",
url.toString() );
throw new IllegalArgumentException( error );
}

- private File getFile( URL url ) throws IllegalArgumentException
+ private File getFile( URL url )
+ throws IllegalArgumentException
{
- if( url.getProtocol().equals( "file" ) )
+ boolean isFileProtocol = "file".equals( url.getProtocol() );
+ if( isFileProtocol )
{
return new File( url.toString().substring( 5 ) );
}
- final String error =
- REZ.getString(
- "scanner.not-file-protocol.error",
- url.toString() );
+ String error = REZ.getString( "scanner.not-file-protocol.error",
url.toString() );
throw new IllegalArgumentException( error );
}

@@ -630,12 +498,15 @@
}
}

- private URL getJarURL( URL url ) throws MalformedURLException
+ private URL getJarURL( URL url )
+ throws MalformedURLException
{
- if( url.getProtocol().equals( "jar" ) )
+ boolean isJarProtocol = "jar".equals( url.getProtocol() );
+ if( isJarProtocol )
{
return url;
- } else
+ }
+ else
{
return new URL( "jar:" + url.toString() + "!/" );
}

Modified:
development/laboratory/users/niclas/osgi/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/ServiceBuilder.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/ServiceBuilder.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/meta/impl/src/main/net/dpml/meta/info/builder/impl/ServiceBuilder.java
Mon Jun 20 03:59:00 2005
@@ -55,10 +55,10 @@
*
* @param clazz The class of Component
* @return the created Service
- * @throws Exception if an error occurs
+ * @throws BuildException if an error occurs
*/
public Service build( Class clazz )
- throws Exception
+ throws BuildException
{
String classname = clazz.getName();
ClassLoader classLoader = clazz.getClassLoader();
@@ -72,10 +72,10 @@
* @param classname The classname of Component
* @param classLoader the ClassLoader to load info from
* @return the created Service
- * @throws Exception if an error occurs
+ * @throws BuildException if an error occurs
*/
public Service build( String classname, ClassLoader classLoader )
- throws Exception
+ throws BuildException
{
final Service info = buildFromSerDescriptor( classname, classLoader
);
if( null != info )
@@ -94,10 +94,10 @@
* @param classname The classname of Component
* @param classLoader the ClassLoader to load info from
* @return the created Service
- * @throws Exception if an error occurs
+ * @throws BuildException if an error occurs
*/
private Service buildFromSerDescriptor( String classname, ClassLoader
classLoader )
- throws Exception
+ throws BuildException
{
final String xinfo = classname.replace( '.', '/' ) + ".sinfo";
final InputStream inputStream = classLoader.getResourceAsStream(
xinfo );

Modified:
development/laboratory/users/niclas/osgi/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/system/impl/src/main/net/dpml/system/impl/DefaultSystemContext.java
Mon Jun 20 03:59:00 2005
@@ -29,14 +29,15 @@


/**
- * The system context class provides access to a logging manager,
- * repository, working and temporary directories, and system level flags and
- * services supporting the deployment of plugins.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
-public class DefaultSystemContext extends DefaultContext implements
SystemContext
+* The system context class provides access to a logging manager,
+* repository, working and temporary directories, and system level flags and
+* services supporting the deployment of plugins.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
+public class DefaultSystemContext extends DefaultContext
+ implements SystemContext
{
//
------------------------------------------------------------------------
// immutable state
@@ -58,10 +59,8 @@
// constructors
//
------------------------------------------------------------------------

- DefaultSystemContext(
- final Repository repository,
- final Logger logger, final File home, final File work, final File
anchor, final File temp,
- final boolean info, final boolean debug, final boolean isolate,
String[] remainder, Properties properties )
+ DefaultSystemContext( Repository repository, Logger logger, File home,
File work, File anchor, File temp,
+ boolean info, boolean debug, boolean isolate,
String[] remainder, Properties properties )
throws NullArgumentException
{
super();

Modified:
development/laboratory/users/niclas/osgi/metro/system/spi/src/main/net/dpml/system/SystemContext.java
==============================================================================
---
development/laboratory/users/niclas/osgi/metro/system/spi/src/main/net/dpml/system/SystemContext.java
(original)
+++
development/laboratory/users/niclas/osgi/metro/system/spi/src/main/net/dpml/system/SystemContext.java
Mon Jun 20 03:59:00 2005
@@ -26,34 +26,26 @@
import java.util.Properties;

/**
- * The controller class manages the deployment of a set of plugins.
- *
- * @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
- * @version $Id$
- */
+* The controller class manages the deployment of a set of plugins.
+*
+* @author <a href="http://www.dpml.net";>The Digital Product Meta Library</a>
+* @version $Id$
+*/
public interface SystemContext extends Context
{
- static final String DOMAIN = "dpml";
- static final String HOME_SYMBOL = DOMAIN.toUpperCase() + "_HOME";
- static final String LINE =
-
"\n--------------------------------------------------------------------------";
-
- static final String GROUP = DOMAIN + ".system";
-
- static final String DIR_KEY = GROUP + ".dir";
- static final String LOGGING_IMPLEMENTATION_KEY = GROUP +
".logging.artifact";
- static final String LOGGING_CONFIGURATION_KEY = GROUP +
".logging.config";
-
- static final String HOME_KEY = GROUP + ".home";
- static final String TEMP_KEY = GROUP + ".temp";
- static final String ANCHOR_KEY = GROUP + ".anchor";
- static final String ISOLATE_KEY = GROUP + ".isolate";
+ static final String LINE =
"\n--------------------------------------------------------------------------";
+ static final String DOMAIN = "dpml";
+ static final String HOME_SYMBOL = DOMAIN.toUpperCase() + "_HOME";
+ static final String GROUP = DOMAIN + ".system";
+ static final String DIR_KEY = GROUP + ".dir";
+ static final String HOME_KEY = GROUP + ".home";
+ static final String TEMP_KEY = GROUP + ".temp";
+ static final String ANCHOR_KEY = GROUP + ".anchor";
+ static final String ISOLATE_KEY = GROUP + ".isolate";

static final String[] KEYS = new String[]
{
DIR_KEY,
- LOGGING_IMPLEMENTATION_KEY,
- LOGGING_CONFIGURATION_KEY,
HOME_KEY,
TEMP_KEY,
ISOLATE_KEY



  • svn commit: r2894 - in development/laboratory/users/niclas/osgi/metro: activation/impl/src/main/net/dpml/activation/impl activation/providers/metro/src/main/net/dpml/activation/metro composition/impl/src/main/net/dpml/composition/model/impl logging/providers meta/impl/src/main/net/dpml/meta/info/builder/impl system/impl/src/main/net/dpml/system/impl system/spi/src/main/net/dpml/system, niclas, 06/20/2005

Archive powered by MHonArc 2.6.24.

Top of Page