All Downloads are FREE. Search and download functionalities are using the official Maven repository.

jadex.bridge.service.ProvidedServiceImplementation Maven / Gradle / Ivy

Go to download

Jadex bridge is a base package for kernels and platforms, i.e., it is used by both and provides commonly used interfaces and classes for active components and their management.

There is a newer version: 4.0.267
Show newest version
package jadex.bridge.service;

import java.util.ArrayList;
import java.util.List;

import jadex.bridge.modelinfo.UnparsedExpression;
import jadex.bridge.service.component.BasicServiceInvocationHandler;

/**
 *  Contains information for provided service implementation:
 *  - implementation class or
 *  - creation expression or
 *  - implementation forward to other component via binding 
 */
public class ProvidedServiceImplementation	extends UnparsedExpression
{
	//-------- attributes --------
	
	/** The binding for forwarding service calls. */
	protected RequiredServiceBinding binding;

	/** The proxy type. */
	protected String proxytype;
	
	/** The list of interceptors. */
	protected List interceptors;
	
	//-------- constructors --------
	
	/**
	 *  Create a new service implementation.
	 */
	public ProvidedServiceImplementation()
	{
		// bean constructor.
		
		// Set default proxy type (Hack!!! specify in xml mapping?)
		proxytype	= BasicServiceInvocationHandler.PROXYTYPE_DECOUPLED;
	}
	
	/**
	 *  Create a new service implementation.
	 */
	public ProvidedServiceImplementation(Class implementation, String expression, 
		String proxytype, RequiredServiceBinding binding, UnparsedExpression[] interceptors)
	{
		super(null, implementation, expression, null);
		this.proxytype = proxytype;
		this.binding = binding;
		if(interceptors!=null)
		{
			for(int i=0; i();
		interceptors.add(interceptor);
	}
	
	/**
	 *  Remove an interceptor.
	 *  @param interceptor The interceptor.
	 */
	public void removeInterceptor(UnparsedExpression interceptor)
	{
		interceptors.remove(interceptor);
	}
	
	/**
	 *  Get the interceptors.
	 *  @return All interceptors.
	 */
	public UnparsedExpression[] getInterceptors()
	{
		return interceptors==null? new UnparsedExpression[0]: 
			interceptors.toArray(new UnparsedExpression[interceptors.size()]);
	}
	
	/**
	 *  Get the string representation.
	 */
	public String toString()
	{
		return getClazz()!=null? getClazz().getTypeName(): 
			getValue()!=null? getValue(): binding!=null? 
			binding.getComponentName()!=null? binding.getComponentName(): 
				binding.getComponentType(): "";
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy