Package org.apache.muse.core.descriptor

Source Code of org.apache.muse.core.descriptor.ResourceDefinition

/*=============================================================================*
*  Copyright 2006 The Apache Software Foundation
*
*  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 org.apache.muse.core.descriptor;

import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import java.util.logging.Logger;

import javax.xml.namespace.QName;

import org.apache.muse.core.Capability;
import org.apache.muse.core.Environment;
import org.apache.muse.core.Resource;
import org.apache.muse.core.routing.ResourceIdFactory;
import org.apache.muse.util.ReflectUtils;
import org.apache.muse.ws.addressing.EndpointReference;

/**
*
* @author Dan Jemiolo (danj)
*
*/

public class ResourceDefinition
{
    private Collection _capabilities = null;
   
    private String _contextPath = null;
   
    private Environment _environment = null;
   
    private ResourceIdFactory _idFactory = null;
   
    private boolean _isUsingPersistence = false;
   
    private Logger _log = null;
   
    private Map _parameters = null;
   
    private Class _resourceClass = null;
   
    private WsdlConfig _wsdl = null;
   
    public Collection getCapabilityDefinitions()
    {
        return _capabilities;
    }
   
    public String getContextPath()
    {
        return _contextPath;
    }
   
    public Environment getEnvironment()
    {
        return _environment;
    }
   
    public Map getInitializationParameters()
    {
        return _parameters;
    }
   
    public Logger getLog()
    {
        return _log;
    }
   
    public Class getResourceClass()
    {
        return _resourceClass;
    }
   
    public ResourceIdFactory getResourceIdFactory()
    {
        return _idFactory;
    }
   
    public WsdlConfig getWsdlConfig()
    {
        return _wsdl;
    }
   
    public boolean isUsingPersistence()
    {
        return _isUsingPersistence;
    }
   
    public Resource newInstance()
    {
        Environment env = getEnvironment();
        Logger log = getLog();
       
        //
        // instantiate the resource object itself
        //
        Class resourceClass = getResourceClass();
        Resource resource = (Resource)ReflectUtils.newInstance(resourceClass);
       
        //
        // give the resource access to all the standard Muse components
        //
        resource.setEnvironment(env);
        resource.setLog(log);
        resource.setContextPath(getContextPath());
        resource.setInitializationParameters(getInitializationParameters());
       
        WsdlConfig wsdl = getWsdlConfig();
        resource.setWsdlPath(wsdl.getWsdlPath());
        resource.setWsdlPortType(wsdl.getWsdlPortType());
       
        //
        // create the unique EPR for the resource using the
        // ID factory specified
        //
        EndpointReference uniqueEPR = env.getDeploymentEPR();
       
        ResourceIdFactory idFactory = getResourceIdFactory();
       
        if (idFactory != null)
        {
            QName id = idFactory.getIdentifierName();
            String value = idFactory.getNextIdentifier();
            uniqueEPR.addParameter(id, value);
        }
       
        resource.setEndpointReference(uniqueEPR);
       
        //
        // add all of the capabilities to the resource
        //
        Iterator i = getCapabilityDefinitions().iterator();
       
        while (i.hasNext())
        {
            CapabilityDefinition next = (CapabilityDefinition)i.next();
            Capability capability = next.newInstance();           
            resource.addCapability(capability);
        }
       
        return resource;
    }
   
    public void setCapabilityDefinitions(Collection capabilities)
    {
        _capabilities = capabilities;
    }
   
    public void setContextPath(String contextPath)
    {
        _contextPath = contextPath;
    }
   
    public void setEnvironment(Environment environment)
    {
        _environment = environment;
    }
   
    public void setInitializationParameters(Map parameters)
    {
        _parameters = parameters;
    }
   
    public void setLog(Logger log)
    {
        _log = log;
    }
   
    public void setResourceClass(Class resourceClass)
    {
        _resourceClass = resourceClass;
    }
   
    public void setResourceIdFactory(ResourceIdFactory idFactory)
    {
        _idFactory = idFactory;
    }
   
    public void setUsingPersistence(boolean isUsingPersistence)
    {
        _isUsingPersistence = isUsingPersistence;
    }
   
    public void setWsdlConfig(WsdlConfig wsdl)
    {
        _wsdl = wsdl;
    }
}
TOP

Related Classes of org.apache.muse.core.descriptor.ResourceDefinition

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.