actions. When using session
scope, setting the "active" property to false at page completion is recommended to
guarantee timely freeing of any resources that may remain assigned while it is the
active context.
Although an explicit destroy method exists, contexts associated with
unreferenced beans will automatically be destroyed as a result of garbage collection.
To be effective, some property of the bean must be set within a thread prior
to calling Windchill APIs that should execute under the bean's implicit context.
Setting a property allows the bean instance to activate its context in the current
thread. Typically, this will be the "request" property. The calling thread's
association to the bean's context remains in effect until explicitly undone through
calls to the WTContext class or by constructing or setting properties on
a different WTContextBean instance.
NOTE: Including or forwarding requests to Windchill gateway URLs will disassociate
the bean's context from the calling thread. It can be reactivated upon return from
an include by setting the "active" property.
Example request scope usage:
<jsp:useBean id="wtcontext" class="wt.httpgw.WTContextBean" scope="request"/>
<jsp:setProperty name="wtcontext" property="request" value="<%=request%>"/>
When the containing JVM also hosts Windchill services, the server-side
execution context, a MethodContext, is also established for
the current thread. Therefore, this bean can be used in the same servlet
JVM that hosts both HTTPGatewayServlet and WTServlet.
NOTE: When a page is invoked via forwarding through the HTTPGatewayServlet
or WTServlet servlets, it is not necessary for to use
WTContextBean objects. These servlets establish the necessary execution
environment before dispatching forwarded requests.
Example forwarding Windchill URL:
http://windchill.acme.com/WindchillAuthGW/forward/mypage.jsp
Supported API: true
Extendable: true
- See Also:
WTContext,
Serialized Form
|
Constructor Summary |
WTContextBean()
Construct a Windchill client execution context (WTContext) bean. |
|
Method Summary |
protected void |
activateClientContext()
Perform context activation when running remote from Windchill services. |
protected void |
activateServerContext()
Perform context activation when running within a Windchill server. |
protected void |
deactivateClientContext()
Perform context deactivation when running remote from Windchill services. |
void |
destroy()
Destroy this bean and the corresonding WTContext. |
MethodAuthenticator |
getAuthentication()
Get the method authenticator currently in effect for this bean. |
protected void |
initClientContext()
Perform default initialization when running remote from Windchill services. |
protected void |
initServerContext()
Perform default initialization when running within a Windchill server. |
static boolean |
isBeanContext(WTContext context)
Test if a WTContext corresponds to a WTContextBean. |
void |
setActive(boolean active)
Activate the context associated with this bean. |
void |
setAuthentication(MethodAuthenticator auth)
Set method authenticator for this bean. |
void |
setRequest(HttpServletRequest request)
Set the HTTP request property of this bean. |
void |
setSession(boolean session)
Set whether or not calls originating from this context are associated with
a persistent Windchill session. |
WTContextBean
public WTContextBean()
- Construct a Windchill client execution context (WTContext) bean.
A unique
WTContext object will be associated to this
bean and the current thread, but the execution context is not fully
initialized until one of the beans properties is set (e.g. request or
active).
The new WTContext defaults certain characteristics to those appropriate
for contexts running in a shared middle-tier (multi-user) server. These
include private authentication and server affinity, and disallowing
user interaction to perform authentication with remote Windchill servers.
Supported API: true
initClientContext
protected void initClientContext()
- Perform default initialization when running remote from Windchill services.
This implementation sets private authentication and server affinity and
disallows user interaction to perform Windchill authentication.
Supported API: true
initServerContext
protected void initServerContext()
- Perform default initialization when running within a Windchill server.
This implementation does nothing.
Supported API: true
destroy
public void destroy()
- Destroy this bean and the corresonding
WTContext.
This method is used to explicitly free resources associated with
this context. If not destroyed, the resources may not be freed
until some time after the bean is garbage collected.
Supported API: true
setRequest
public void setRequest(HttpServletRequest request)
- Set the HTTP request property of this bean.
The context associated with this bean will become the active context for the current
thread and be initialized based on HTTP request properties. This property must be set
on beans used in Java Server Pages (JSP) or Servlets to establish Windchill user
authentication based on the current request's HTTP authentication.
Other initialization includes setting the locale of the corresponding
WTContext based on the Accept-Language HTTP header of this request.
Supported API: true
- Parameters:
request - HTTP servlet request
setActive
public void setActive(boolean active)
- Activate the context associated with this bean.
The context associated with this bean will become the active context for the
current thread. This property can be set in order to re-activate an existing bean.
Supported API: true
- Parameters:
active - true to activate, false to deactivate
setAuthentication
public void setAuthentication(MethodAuthenticator auth)
- Set method authenticator for this bean.
The context associated with this bean will become the active context for the
current thread and the given authenticator will be used for subsequent user
authentication. When the bean is in a client, this authenticator will be used as-is
to endorse outgoing calls to the default Windchill method server. When the bean is in
a Windchill server, this authenticator will be bootstrapped through a call to
wt.auth.AuthenticationServer.init.
Supported API: true
- Parameters:
auth - method authenticator
getAuthentication
public MethodAuthenticator getAuthentication()
- Get the method authenticator currently in effect for this bean.
Supported API: true
- Parameters:
auth - method authenticator
setSession
public void setSession(boolean session)
- Set whether or not calls originating from this context are associated with
a persistent Windchill session. By default, calls are associated with
transient sessions that exist only for the duration of each call. If this
property is set to true, then the next authenticator set for this context
via
setRequest or setAuthentication will be initialized
via its init method to bootstrap a persistent session. Once a session
is established, subsequent calls to setRequest will be ignored.
Supported API: true
- Parameters:
auth - method authenticator
isBeanContext
public static boolean isBeanContext(WTContext context)
- Test if a WTContext corresponds to a WTContextBean.
Supported API: true
- Parameters:
context - the WTContext to check
activateClientContext
protected void activateClientContext()
- Perform context activation when running remote from Windchill services.
This implementation makes this bean's method authenticator the current
authenticator for calls originating from this context to the default
method server.
Supported API: true
deactivateClientContext
protected void deactivateClientContext()
- Perform context deactivation when running remote from Windchill services.
This implementation does nothing.
Supported API: true
activateServerContext
protected void activateServerContext()
- Perform context activation when running within a Windchill server.
This implementation registers a
MethodContext for the
current thread and bootstraps the beans method authenticator.
Supported API: true