Package jadex.bridge.service.search
Class ServiceQuery<T>
- java.lang.Object
-
- jadex.bridge.service.search.ServiceQuery<T>
-
public class ServiceQuery<T> extends java.lang.Object
Service query definition. T is the return type for search methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
ServiceQuery.Multiplicity
Define cases for multiplicity.
-
Field Summary
Fields Modifier and Type Field Description static java.util.Map<java.lang.String,java.lang.Boolean>
DEFAULT_MATCHINGMODES
Default matching modes set the elements with OR semantics.protected boolean
eventmode
Flag if event mode is enabled on the query.protected boolean
excludeowner
Flag, if service by the query owner should be excluded, i.e.protected java.lang.String
id
The query id.protected java.util.Map<java.lang.String,java.lang.Boolean>
matchingmodes
The matching mode for multivalued terms.protected ServiceQuery.Multiplicity
multiplicity
The multiple flag.protected java.lang.String[]
networknames
The network names.static java.lang.String[]
NETWORKS_NOT_SET
Marker for networks not set.protected IComponentIdentifier
owner
The query owner.protected IComponentIdentifier
platform
The service platform.static java.lang.String
PROXYTYPE_DECOUPLED
The (default) decoupled proxy type (decouples from component thread to caller thread).static java.lang.String
PROXYTYPE_DIRECT
The direct proxy type (supports custom interceptors, but uses caller thread).static java.lang.String
PROXYTYPE_RAW
The raw proxy type (i.e.protected java.lang.String
requiredproxytype
Required service proxy type.protected ServiceScope
scope
The search scope.protected IComponentIdentifier
searchstart
Starting point for the search scoping.protected IServiceIdentifier
serviceidentifier
The service ID of the target service.protected java.lang.String[]
servicetags
Tags of the service.protected ClassInfo
servicetype
The service type.protected java.lang.Boolean
unrestricted
Should the service be unrestricted.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ServiceQuery()
Create a new service query.ServiceQuery(ClassInfo servicetype)
Create a new service query.ServiceQuery(ClassInfo servicetype, ServiceScope scope, IComponentIdentifier owner)
Create a new service query.ServiceQuery(ServiceQuery<T> original)
Shallow copy constructor.ServiceQuery(java.lang.Class<T> servicetype)
Create a new service query.ServiceQuery(java.lang.Class<T> servicetype, ServiceScope scope)
Create a new service query.ServiceQuery(java.lang.Class<T> servicetype, ServiceScope scope, IComponentIdentifier owner)
Create a new service query.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static <T> RequiredServiceInfo
createServiceInfo(ServiceQuery<T> query)
When searching with query -> create required service info from service query.boolean
equals(java.lang.Object obj)
Test if other object equals this one.java.lang.String
getId()
Get the id.java.util.List<Tuple3<java.lang.String,java.lang.String[],java.lang.Boolean>>
getIndexerSearchSpec()
Gets the specification for the indexer.java.lang.Boolean
getMatchingMode(java.lang.String key)
Get the matching mode for a key.ServiceQuery.Multiplicity
getMultiplicity()
Get the multiplicity.java.lang.String[]
getNetworkNames()
Get the networknames.IComponentIdentifier
getOwner()
Get the owner.IComponentIdentifier
getPlatform()
Get the platform.java.lang.String
getRequiredProxyType()
Returns the requested required service proxy type.ServiceScope
getScope()
Get the scope.IComponentIdentifier
getSearchStart()
Get the provider.IServiceIdentifier
getServiceIdentifier()
Gets the service identifier.static <T> ServiceQuery<T>
getServiceQuery(IInternalAccess ia, RequiredServiceInfo info)
When searching for declared service -> map required service declaration to service query.java.lang.String[]
getServiceTags()
Gets the service tags.ClassInfo
getServiceType()
Get the service type.IComponentIdentifier
getTargetPlatform()
Get the target platform if specified (using platform and provider).int
hashCode()
Get the hashcode.boolean
isEventMode()
Checks if query is in event mode.boolean
isExcludeOwner()
Checks if service of the query owner should be excluded.java.lang.Boolean
isUnrestricted()
Get the unrestricted mode.protected boolean
matchesKeys(IServiceIdentifier service)
Tests if the query keys matches a service.ServiceQuery<ServiceEvent>
setEventMode()
Changes the query to event mode.void
setEventMode(boolean eventmode)
Deprecated.For bean purposes only, use setEventMode().ServiceQuery<T>
setExcludeOwner(boolean excludeowner)
Sets if service of the query owner should be excluded.ServiceQuery<T>
setId(java.lang.String id)
Set the id.ServiceQuery<T>
setMatchingMode(java.lang.String key, java.lang.Boolean and)
Set a matching mode.ServiceQuery<T>
setMultiplicity(int multiplicity)
Set the multiplicity.ServiceQuery<T>
setMultiplicity(int multiplicitystart, int multiplicityend)
Set the multiplicity.ServiceQuery<T>
setMultiplicity(ServiceQuery.Multiplicity multiplicity)
Set the multiplicity.ServiceQuery<T>
setNetworkNames(java.lang.String... networknames)
Set the networknames.ServiceQuery<T>
setOwner(IComponentIdentifier owner)
Set the owner.ServiceQuery<T>
setPlatform(IComponentIdentifier platform)
Set the platform.ServiceQuery<T>
setProvider(IComponentIdentifier provider)
Set the provider.ServiceQuery<T>
setRequiredProxyType(java.lang.String requiredproxytype)
Sets the requested required service proxy type.ServiceQuery<T>
setScope(ServiceScope scope)
Set the scope.ServiceQuery<T>
setSearchStart(IComponentIdentifier searchstart)
Set the provider.ServiceQuery<T>
setServiceIdentifier(IServiceIdentifier serviceidentifier)
Sets the service identifier.ServiceQuery<T>
setServiceTags(java.lang.String... servicetags)
Sets the service tags.ServiceQuery<T>
setServiceTags(java.lang.String[] servicetags, IExternalAccess component)
Sets the service tags.ServiceQuery<T>
setServiceType(ClassInfo servicetype)
Set the service type.ServiceQuery<T>
setUnrestricted(java.lang.Boolean unrestricted)
Set the unrestricted mode.java.lang.String
toString()
Get the string representation.
-
-
-
Field Detail
-
PROXYTYPE_RAW
public static final java.lang.String PROXYTYPE_RAW
The raw proxy type (i.e. no proxy).- See Also:
- Constant Field Values
-
PROXYTYPE_DIRECT
public static final java.lang.String PROXYTYPE_DIRECT
The direct proxy type (supports custom interceptors, but uses caller thread).- See Also:
- Constant Field Values
-
PROXYTYPE_DECOUPLED
public static final java.lang.String PROXYTYPE_DECOUPLED
The (default) decoupled proxy type (decouples from component thread to caller thread).- See Also:
- Constant Field Values
-
NETWORKS_NOT_SET
public static final java.lang.String[] NETWORKS_NOT_SET
Marker for networks not set.
-
DEFAULT_MATCHINGMODES
public static final java.util.Map<java.lang.String,java.lang.Boolean> DEFAULT_MATCHINGMODES
Default matching modes set the elements with OR semantics.
-
servicetype
protected ClassInfo servicetype
The service type.
-
servicetags
protected java.lang.String[] servicetags
Tags of the service.
-
searchstart
protected IComponentIdentifier searchstart
Starting point for the search scoping.
-
platform
protected IComponentIdentifier platform
The service platform. (Find a service from another known platform, e.g. cms)
-
serviceidentifier
protected IServiceIdentifier serviceidentifier
The service ID of the target service. Fast lookup of a service by id.
-
networknames
protected java.lang.String[] networknames
The network names.
-
unrestricted
protected java.lang.Boolean unrestricted
Should the service be unrestricted.
-
scope
protected ServiceScope scope
The search scope.
-
owner
protected IComponentIdentifier owner
The query owner. (rename queryowner?)
-
excludeowner
protected boolean excludeowner
Flag, if service by the query owner should be excluded, i.e. do not return my own service.
-
multiplicity
protected ServiceQuery.Multiplicity multiplicity
The multiple flag. Search for multiple services
-
eventmode
protected boolean eventmode
Flag if event mode is enabled on the query.
-
matchingmodes
protected java.util.Map<java.lang.String,java.lang.Boolean> matchingmodes
The matching mode for multivalued terms. True is and and false is or.
-
requiredproxytype
protected java.lang.String requiredproxytype
Required service proxy type.
-
id
protected java.lang.String id
The query id. Id is used for hashcode and equals and the same is used by servicequeryinfo class. Allows for hashing queryies and use a queryinfo object for lookup.
-
-
Constructor Detail
-
ServiceQuery
protected ServiceQuery()
Create a new service query.
-
ServiceQuery
public ServiceQuery(java.lang.Class<T> servicetype)
Create a new service query.
-
ServiceQuery
public ServiceQuery(java.lang.Class<T> servicetype, ServiceScope scope)
Create a new service query.
-
ServiceQuery
public ServiceQuery(java.lang.Class<T> servicetype, ServiceScope scope, IComponentIdentifier owner)
Create a new service query.
-
ServiceQuery
public ServiceQuery(ClassInfo servicetype)
Create a new service query.
-
ServiceQuery
public ServiceQuery(ClassInfo servicetype, ServiceScope scope, IComponentIdentifier owner)
Create a new service query.
-
ServiceQuery
public ServiceQuery(ServiceQuery<T> original)
Shallow copy constructor.- Parameters:
original
- Original query.
-
-
Method Detail
-
getServiceType
public ClassInfo getServiceType()
Get the service type.- Returns:
- The service type
-
setServiceType
public ServiceQuery<T> setServiceType(ClassInfo servicetype)
Set the service type.- Parameters:
type
- The service type to set
-
setEventMode
@Deprecated public void setEventMode(boolean eventmode)
Deprecated.For bean purposes only, use setEventMode().Changes the query to event mode.- Parameters:
eventmode
- the event mode state.
-
setEventMode
public ServiceQuery<ServiceEvent> setEventMode()
Changes the query to event mode.- Returns:
- The new query.
-
isEventMode
public boolean isEventMode()
Checks if query is in event mode.- Returns:
- True, if in event mode
-
getScope
public ServiceScope getScope()
Get the scope.- Returns:
- The scope
-
setScope
public ServiceQuery<T> setScope(ServiceScope scope)
Set the scope.- Parameters:
scope
- The scope to set
-
getServiceTags
public java.lang.String[] getServiceTags()
Gets the service tags.- Returns:
- The service tags.
-
setServiceTags
public ServiceQuery<T> setServiceTags(java.lang.String... servicetags)
Sets the service tags.- Parameters:
servicetags
- The service tags.
-
setServiceTags
public ServiceQuery<T> setServiceTags(java.lang.String[] servicetags, IExternalAccess component)
Sets the service tags.- Parameters:
servicetags
- The service tags. todo: move or refactor to hide complexity!?
-
setProvider
public ServiceQuery<T> setProvider(IComponentIdentifier provider)
Set the provider.- Parameters:
provider
- The provider to set
-
getSearchStart
public IComponentIdentifier getSearchStart()
Get the provider.- Returns:
- The provider
-
setSearchStart
public ServiceQuery<T> setSearchStart(IComponentIdentifier searchstart)
Set the provider.- Parameters:
provider
- The provider to set
-
getPlatform
public IComponentIdentifier getPlatform()
Get the platform.- Returns:
- The platform
-
setPlatform
public ServiceQuery<T> setPlatform(IComponentIdentifier platform)
Set the platform.- Parameters:
platform
- The platform
-
getServiceIdentifier
public IServiceIdentifier getServiceIdentifier()
Gets the service identifier.- Returns:
- The service identifier.
-
setServiceIdentifier
public ServiceQuery<T> setServiceIdentifier(IServiceIdentifier serviceidentifier)
Sets the service identifier. Also sets the corresponding provider when sid!=null.- Parameters:
serviceidentifier
- The service identifier.
-
getOwner
public IComponentIdentifier getOwner()
Get the owner.- Returns:
- The owner
-
setOwner
public ServiceQuery<T> setOwner(IComponentIdentifier owner)
Set the owner.- Parameters:
owner
- The owner to set
-
isExcludeOwner
public boolean isExcludeOwner()
Checks if service of the query owner should be excluded.- Returns:
- True, if the services should be excluded.
-
setExcludeOwner
public ServiceQuery<T> setExcludeOwner(boolean excludeowner)
Sets if service of the query owner should be excluded.- Parameters:
excludeowner
- True, if the services should be excluded.
-
getId
public java.lang.String getId()
Get the id.- Returns:
- the id
-
setId
public ServiceQuery<T> setId(java.lang.String id)
Set the id.- Parameters:
id
- The id to set
-
getMultiplicity
public ServiceQuery.Multiplicity getMultiplicity()
Get the multiplicity.- Returns:
- the multiplicity
-
setMultiplicity
public ServiceQuery<T> setMultiplicity(int multiplicity)
Set the multiplicity.- Parameters:
multiplicity
- The minimum multiplicity to set
-
setMultiplicity
public ServiceQuery<T> setMultiplicity(int multiplicitystart, int multiplicityend)
Set the multiplicity.- Parameters:
multiplicitystart
- The minimum multiplicity to setmultiplicityend
- The max multiplicity to set
-
setMultiplicity
public ServiceQuery<T> setMultiplicity(ServiceQuery.Multiplicity multiplicity)
Set the multiplicity.- Parameters:
multiplicity
- The multiplicity to set
-
getIndexerSearchSpec
public java.util.List<Tuple3<java.lang.String,java.lang.String[],java.lang.Boolean>> getIndexerSearchSpec()
Gets the specification for the indexer. Query needs to be enhanced before calling this method. See RequiredServiceFeature.enhanceQuery()- Returns:
- The specification for the indexer.
-
getMatchingMode
public java.lang.Boolean getMatchingMode(java.lang.String key)
Get the matching mode for a key.- Parameters:
key
- The key name.- Returns:
- True for and, false for or.
-
setMatchingMode
public ServiceQuery<T> setMatchingMode(java.lang.String key, java.lang.Boolean and)
Set a matching mode.- Parameters:
key
- The key name.and
- True for and.
-
isUnrestricted
public java.lang.Boolean isUnrestricted()
Get the unrestricted mode.- Returns:
- The unrestricted mode.
-
setUnrestricted
public ServiceQuery<T> setUnrestricted(java.lang.Boolean unrestricted)
Set the unrestricted mode.- Parameters:
unrestricted
- the unrestricted to set
-
matchesKeys
protected boolean matchesKeys(IServiceIdentifier service)
Tests if the query keys matches a service.- Parameters:
service
- The service.- Returns:
- True, if the service matches the keys.
-
getNetworkNames
public java.lang.String[] getNetworkNames()
Get the networknames.- Returns:
- the networknames
-
setNetworkNames
public ServiceQuery<T> setNetworkNames(java.lang.String... networknames)
Set the networknames.- Parameters:
networknames
- The networknames to set
-
getRequiredProxyType
public java.lang.String getRequiredProxyType()
Returns the requested required service proxy type.- Returns:
- The requested required service proxy type.
-
setRequiredProxyType
public ServiceQuery<T> setRequiredProxyType(java.lang.String requiredproxytype)
Sets the requested required service proxy type.- Parameters:
requiredproxytype
- The requested required service proxy type.
-
hashCode
public int hashCode()
Get the hashcode.- Overrides:
hashCode
in classjava.lang.Object
-
equals
public boolean equals(java.lang.Object obj)
Test if other object equals this one.- Overrides:
equals
in classjava.lang.Object
-
getTargetPlatform
public IComponentIdentifier getTargetPlatform()
Get the target platform if specified (using platform and provider).- Returns:
- The target platform.
-
getServiceQuery
public static <T> ServiceQuery<T> getServiceQuery(IInternalAccess ia, RequiredServiceInfo info)
When searching for declared service -> map required service declaration to service query.
-
createServiceInfo
public static <T> RequiredServiceInfo createServiceInfo(ServiceQuery<T> query)
When searching with query -> create required service info from service query.
-
toString
public java.lang.String toString()
Get the string representation.- Overrides:
toString
in classjava.lang.Object
-
-