donaldp 2002/06/14 01:00:47
Added: containerkit/src/java/org/apache/excalibur/containerkit/kernel
AbstractServiceKernel.java
KernelResourceAccessor.java
Log:
Temporary checkin to move computers.
Revision Changes Path
1.1
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/AbstractServiceKernel.java
Index: AbstractServiceKernel.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.containerkit.kernel;
/**
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/06/14 08:00:47 $
*/
public abstract class AbstractServiceKernel
{
protected abstract Object getComponent( String name );
protected abstract Object getContextValue( String name, Object entry );
}
1.1
jakarta-avalon-excalibur/containerkit/src/java/org/apache/excalibur/containerkit/kernel/KernelResourceAccessor.java
Index: KernelResourceAccessor.java
===================================================================
/*
* Copyright (C) The Apache Software Foundation. All rights reserved.
*
* This software is published under the terms of the Apache Software License
* version 1.1, a copy of which has been included with this distribution in
* the LICENSE.txt file.
*/
package org.apache.excalibur.containerkit.kernel;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.excalibur.i18n.ResourceManager;
import org.apache.avalon.excalibur.i18n.Resources;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.excalibur.containerkit.lifecycle.ResourceAccessor;
import org.apache.excalibur.containerkit.metadata.ComponentMetaData;
import org.apache.excalibur.containerkit.metainfo.ContextDescriptor;
import org.apache.excalibur.containerkit.metainfo.EntryDescriptor;
/**
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Peter Donald</a>
* @version $Revision: 1.1 $ $Date: 2002/06/14 08:00:47 $
*/
public abstract class KernelResourceAccessor
implements ResourceAccessor
{
private final static Resources REZ =
ResourceManager.getPackageResources( KernelResourceAccessor.class );
private final AbstractServiceKernel m_kernel;
public KernelResourceAccessor( final AbstractServiceKernel kernel )
{
m_kernel = kernel;
}
public Context createContext( Object entry )
throws Exception
{
final ComponentMetaData component = getMetaData( entry );
final ContextDescriptor descriptor =
component.getComponentInfo().getContextDescriptor();
final Map contextData = new HashMap();
final EntryDescriptor[] entrys = descriptor.getEntrys();
for( int i = 0; i < entrys.length; i++ )
{
final String key = entrys[ i ].getKey();
final String type = entrys[ i ].getType();
final boolean optional = entrys[ i ].isOptional();
final Object value =
m_kernel.getContextValue( key, entry );
if( null == value && !optional )
{
if( !optional )
{
final String message =
REZ.getString( "resource.missing-context-value.error",
key,
component.getName() );
throw new Exception( message );
}
else
{
continue;
}
}
final Class clazz = value.getClass();
final Class typeClass = clazz.getClassLoader().loadClass( type );
if( !typeClass.isAssignableFrom( clazz ) )
{
final String message =
REZ.getString( "resource.bad-value-type.error",
key,
type,
clazz.getName(),
component.getName() );
throw new Exception( message );
}
}
return null;
}
protected ComponentMetaData getMetaData( final Object entry )
{
return (ComponentMetaData)entry;
}
/**
* Create a new ComponentManager for component.
*
* @param entry the entry
* @return a new ComponentManager for component
* @throws Exception if unable to create resource
*/
public ComponentManager createComponentManager( Object entry )
throws Exception
{
return null;
}
/**
* Create a new ServiceManager for component.
*
* @param entry the entry
* @return a new ServiceManager for component
* @throws Exception if unable to create resource
*/
public ServiceManager createServiceManager( Object entry )
throws Exception
{
return null;
}
}
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>