/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you 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 org.apache.muse.core.descriptor;
import java.util.Collection;
import java.util.logging.Logger;
import org.apache.muse.core.Environment;
import org.apache.muse.core.routing.ResourceRouter;
import org.apache.muse.core.routing.RouterPersistence;
import org.apache.muse.util.ReflectUtils;
/**
*
* @author Dan Jemiolo (danj)
*
*/
public class RouterDefinition
{
private Environment _environment = null;
private LoggingConfig _logging = null;
private PersistenceDefinition _persistence = null;
private Collection _resourceDefinitions = null;
private Class _theClass = null;
public Environment getEnvironment()
{
return _environment;
}
public LoggingConfig getLoggingConfig()
{
return _logging;
}
public PersistenceDefinition getPersistenceDefinition()
{
return _persistence;
}
public Collection getResourceDefinitions()
{
return _resourceDefinitions;
}
public Class getRouterClass()
{
return _theClass;
}
public ResourceRouter newInstance()
{
Class theClass = getRouterClass();
ResourceRouter router = (ResourceRouter)ReflectUtils.newInstance(theClass);
Environment env = getEnvironment();
router.setEnvironment(env);
LoggingConfig logging = getLoggingConfig();
Logger log = logging.newInstance();
router.setLog(log);
router.setResourceDefinitions(getResourceDefinitions());
PersistenceDefinition persistenceDef = getPersistenceDefinition();
if (persistenceDef != null)
{
RouterPersistence persistence = (RouterPersistence)persistenceDef.newInstance();
router.setPersistence(persistence);
}
return router;
}
public void setEnvironment(Environment environment)
{
_environment = environment;
}
public void setLoggingConfig(LoggingConfig logging)
{
_logging = logging;
}
public void setPersistenceDefinition(PersistenceDefinition persistence)
{
_persistence = persistence;
}
public void setResourceDefinitions(Collection resourceDefinitions)
{
_resourceDefinitions = resourceDefinitions;
}
public void setRouterClass(Class theClass)
{
_theClass = theClass;
}
}