Package org.jboss.ejb.client
Class EJBLocator<T>
- java.lang.Object
-
- org.jboss.ejb.client.EJBLocator<T>
-
- Type Parameters:
T- the interface type
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
EJBHomeLocator,EntityEJBLocator,StatefulEJBLocator,StatelessEJBLocator
public abstract class EJBLocator<T> extends Object implements Serializable
An identifier for an EJB proxy invocation target instance, suitable for use as a hash key or a serialized token.- See Also:
- Serialized Form
-
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description StatefulEJBLocator<T>asStateful()Return this locator as a stateful locator, if it is one.StatelessEJBLocator<T>asStateless()Return this locator as a stateless locator, if it is one.booleancanNarrowTo(Class<?> type)Determine whether anarrowTo(Class)operation would succeed.TcreateProxyInstance(InvocationHandler invocationHandler)Create a proxy instance using the cached proxy class.booleanequals(Object other)Determine whether this object is equal to another.booleanequals(EJBLocator<?> other)Determine whether this object is equal to another.AffinitygetAffinity()Get the locator affinity.StringgetAppName()Get the application name.StringgetBeanName()Get the EJB bean name.StringgetDistinctName()Get the module distinct name.EJBIdentifiergetIdentifier()Get the EJB identifier for this locator.StringgetModuleName()Get the module name.Class<? extends T>getProxyClass()Get the proxy class for this locator.Constructor<? extends T>getProxyConstructor()Get the proxy class constructor for this locator.Class<T>getViewType()Get the view type of this locator.inthashCode()Get the hash code for this instance.booleanisEntity()Determine if this is an entity locator.booleanisHome()Determine if this is a home locator.booleanisStateful()Determine if this is a stateful locator.booleanisStateless()Determine if this is a stateless locator.<S extends javax.ejb.EJBObject>
EntityEJBLocator<? extends S>narrowAsEntity(Class<S> type)Narrow this locator to the target type as a entity locator.<S extends javax.ejb.EJBHome>
EJBHomeLocator<? extends S>narrowAsHome(Class<S> type)Narrow this locator to the target type as a home locator.<S> StatefulEJBLocator<? extends S>narrowAsStateful(Class<S> type)Narrow this locator to the target type as a stateful locator.<S> StatelessEJBLocator<? extends S>narrowAsStateless(Class<S> type)Narrow this locator to the target type as a stateless locator.<S> EJBLocator<? extends S>narrowTo(Class<S> type)Narrow this locator to the target type.StringtoString()abstract EJBLocator<T>withNewAffinity(Affinity affinity)Create a copy of this locator, but with the new given affinity.StatefulEJBLocator<T>withSession(SessionID sessionId)Create a copy of this locator, but with the given stateful session ID.StatefulEJBLocator<T>withSessionAndAffinity(SessionID sessionId, Affinity affinity)Create a copy of this locator, but with the given affinity and stateful session ID.
-
-
-
Method Detail
-
withNewAffinity
public abstract EJBLocator<T> withNewAffinity(Affinity affinity)
Create a copy of this locator, but with the new given affinity.- Parameters:
affinity- the new affinity- Returns:
- the new locator
-
withSession
public StatefulEJBLocator<T> withSession(SessionID sessionId)
Create a copy of this locator, but with the given stateful session ID. If this locator cannot be converted, an exception is thrown.- Parameters:
sessionId- the stateful session ID (must not benull)- Returns:
- the new locator (not
null)
-
withSessionAndAffinity
public StatefulEJBLocator<T> withSessionAndAffinity(SessionID sessionId, Affinity affinity)
Create a copy of this locator, but with the given affinity and stateful session ID. If this locator cannot be converted, an exception is thrown.- Parameters:
sessionId- the stateful session ID (must not benull)affinity- the new affinity (must not benull)- Returns:
- the new locator (not
null)
-
canNarrowTo
public boolean canNarrowTo(Class<?> type)
Determine whether anarrowTo(Class)operation would succeed.- Parameters:
type- the type to narrow to- Returns:
trueif the narrow would succeed;falseotherwise
-
narrowTo
public <S> EJBLocator<? extends S> narrowTo(Class<S> type)
Narrow this locator to the target type.- Type Parameters:
S- the target type- Parameters:
type- the target type class- Returns:
- this instance, narrowed to the given type
- Throws:
ClassCastException- if the view type cannot be cast to the given type
-
narrowAsHome
public <S extends javax.ejb.EJBHome> EJBHomeLocator<? extends S> narrowAsHome(Class<S> type)
Narrow this locator to the target type as a home locator.- Type Parameters:
S- the target type- Parameters:
type- the target type class- Returns:
- this instance, narrowed to the given type and cast as a home locator
- Throws:
ClassCastException- if the view type cannot be cast to the given type or if this locator is not a home locator
-
narrowAsEntity
public <S extends javax.ejb.EJBObject> EntityEJBLocator<? extends S> narrowAsEntity(Class<S> type)
Narrow this locator to the target type as a entity locator.- Type Parameters:
S- the target type- Parameters:
type- the target type class- Returns:
- this instance, narrowed to the given type and cast as a entity locator
- Throws:
ClassCastException- if the view type cannot be cast to the given type or if this locator is not a entity locator
-
narrowAsStateful
public <S> StatefulEJBLocator<? extends S> narrowAsStateful(Class<S> type)
Narrow this locator to the target type as a stateful locator.- Type Parameters:
S- the target type- Parameters:
type- the target type class- Returns:
- this instance, narrowed to the given type and cast as a stateful locator
- Throws:
ClassCastException- if the view type cannot be cast to the given type or if this locator is not a stateful locator
-
narrowAsStateless
public <S> StatelessEJBLocator<? extends S> narrowAsStateless(Class<S> type)
Narrow this locator to the target type as a stateless locator.- Type Parameters:
S- the target type- Parameters:
type- the target type class- Returns:
- this instance, narrowed to the given type and cast as a stateless locator
- Throws:
ClassCastException- if the view type cannot be cast to the given type or if this locator is not a stateless locator
-
asStateless
public StatelessEJBLocator<T> asStateless()
Return this locator as a stateless locator, if it is one.- Returns:
- this instance, cast as a stateless locator
- Throws:
ClassCastException- if this locator is not a stateless locator
-
asStateful
public StatefulEJBLocator<T> asStateful()
Return this locator as a stateful locator, if it is one.- Returns:
- this instance, cast as a stateful locator
- Throws:
ClassCastException- if this locator is not a stateful locator
-
isStateless
public boolean isStateless()
Determine if this is a stateless locator. If so, calls toasStateless()andnarrowAsStateless(Class)will generally succeed.- Returns:
trueif this locator is stateless,falseotherwise
-
isStateful
public boolean isStateful()
Determine if this is a stateful locator. If so, calls toasStateful()andnarrowAsStateful(Class)will generally succeed.- Returns:
trueif this locator is stateful,falseotherwise
-
isEntity
public boolean isEntity()
Determine if this is an entity locator. If so, calls tonarrowAsEntity(Class)will generally succeed.- Returns:
trueif this locator is an entity,falseotherwise
-
isHome
public boolean isHome()
Determine if this is a home locator. If so, calls tonarrowAsHome(Class)will generally succeed.- Returns:
trueif this locator is a home,falseotherwise
-
getAppName
public String getAppName()
Get the application name.- Returns:
- the application name
-
getModuleName
public String getModuleName()
Get the module name.- Returns:
- the module name
-
getBeanName
public String getBeanName()
Get the EJB bean name.- Returns:
- the EJB bean name
-
getDistinctName
public String getDistinctName()
Get the module distinct name.- Returns:
- the module distinct name
-
getAffinity
public Affinity getAffinity()
Get the locator affinity.- Returns:
- the locator affinity
-
getIdentifier
public EJBIdentifier getIdentifier()
Get the EJB identifier for this locator.- Returns:
- the EJB identifier
-
hashCode
public final int hashCode()
Get the hash code for this instance.
-
equals
public boolean equals(Object other)
Determine whether this object is equal to another.
-
getProxyClass
public Class<? extends T> getProxyClass()
Get the proxy class for this locator.- Returns:
- the proxy class
-
getProxyConstructor
public Constructor<? extends T> getProxyConstructor()
Get the proxy class constructor for this locator. A proxy class constructor accepts a single argument of typeInvocationHandler.- Returns:
- the proxy constructor
-
createProxyInstance
public T createProxyInstance(InvocationHandler invocationHandler)
Create a proxy instance using the cached proxy class.- Parameters:
invocationHandler- the invocation handler to use- Returns:
- the proxy instance
-
equals
public boolean equals(EJBLocator<?> other)
Determine whether this object is equal to another.- Parameters:
other- the other object- Returns:
trueif they are equal,falseotherwise
-
-