Java Doc for PortletContext.java in  » Portal » Open-Portal » javax » portlet » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Portal » Open Portal » javax.portlet 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


javax.portlet.PortletContext

All known Subclasses:   com.sun.portal.portlet.impl.PortletContextImpl,
PortletContext
public interface PortletContext (Code)
The PortletContext interface defines a portlet view of the portlet container. The PortletContext also makes resources available to the portlet. Using the context, a portlet can access the portlet log, and obtain URL references to resources.

There is one context per "portlet application" per Java Virtual Machine. (A "portlet application" is a collection of portlets, servlets, and content installed under a specific subset of the server URL namespace, such as /catalog. They are possibly installed via a .war file.) As a web application, a portlet application also has a servlet context. The portlet context leverages most of its functionality from the servlet context of the portlet application.

Attibutes stored in the context are global for all users and all components in the portlet application.

In the case of a web application marked "distributed" in its deployment descriptor, there will be one context instance for each virtual machine. In this situation, the context cannot be used as a location to share global information (because the information is not truly global). Use an external resource, such as a database to achieve sharing on a global scope.





Method Summary
public  java.lang.ObjectgetAttribute(java.lang.String name)
     Returns the portlet container attribute with the given name, or null if there is no attribute by that name. An attribute allows a portlet container to give the portlet additional information not already provided by this interface. A list of supported attributes can be retrieved using getAttributeNames.

The attribute is returned as a java.lang.Object or some subclass. Attribute names should follow the same convention as package names.

public  java.util.EnumerationgetAttributeNames()
     Returns an Enumeration containing the attribute names available within this portlet context, or an emtpy Enumeration if no attributes are available.
public  java.lang.StringgetInitParameter(java.lang.String name)
     Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist.
public  java.util.EnumerationgetInitParameterNames()
     Returns the names of the context initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters.
public  intgetMajorVersion()
     Returns the major version of the Portlet API that this portlet container supports.
public  StringgetMimeType(String file)
     Returns the MIME type of the specified file, or null if the MIME type is not known.
public  intgetMinorVersion()
     Returns the minor version of the Portlet API that this portlet container supports.
public  PortletRequestDispatchergetNamedDispatcher(String name)
     Returns a PortletRequestDispatcher object that acts as a wrapper for the named servlet.
public  StringgetPortletContextName()
     Returns the name of this portlet application correponding to this PortletContext as specified in the web.xml deployment descriptor for this web application by the display-name element.
public  StringgetRealPath(String path)
     Returns a String containing the real path for a given virtual path.
public  PortletRequestDispatchergetRequestDispatcher(String path)
     Returns a PortletRequestDispatcher object that acts as a wrapper for the resource located at the given path. A PortletRequestDispatcher object can be used include the resource in a response.
public  java.net.URLgetResource(String path)
     Returns a URL to the resource that is mapped to a specified path.
public  java.io.InputStreamgetResourceAsStream(String path)
     Returns the resource located at the given path as an InputStream object. The data in the InputStream can be of any type or length.
public  java.util.SetgetResourcePaths(String path)
     Returns a directory-like listing of all the paths to resources within the web application longest sub-path of which matches the supplied path argument.
public  StringgetServerInfo()
     Returns the name and version of the portlet container in which the portlet is running.
public  voidlog(java.lang.String msg)
     Writes the specified message to a portlet log file, usually an event log.
public  voidlog(java.lang.String message, java.lang.Throwable throwable)
     Writes an explanatory message and a stack trace for a given Throwable exception to the portlet log file.
public  voidremoveAttribute(java.lang.String name)
     Removes the attribute with the given name from the portlet context.
public  voidsetAttribute(java.lang.String name, java.lang.Object object)
     Binds an object to a given attribute name in this portlet context. If the name specified is already used for an attribute, this method removes the old attribute and binds the name to the new attribute.

If a null value is passed, the effect is the same as calling removeAttribute().

Attribute names should follow the same convention as package names.




Method Detail
getAttribute
public java.lang.Object getAttribute(java.lang.String name)(Code)
Returns the portlet container attribute with the given name, or null if there is no attribute by that name. An attribute allows a portlet container to give the portlet additional information not already provided by this interface. A list of supported attributes can be retrieved using getAttributeNames.

The attribute is returned as a java.lang.Object or some subclass. Attribute names should follow the same convention as package names. The Java Portlet API specification reserves names matching java.*, javax.*, and sun.*.
Parameters:
  name - a String specifying the name of the attribute an Object containing the value of the attribute, or nullif no attribute exists matching the givenname
See Also:   PortletContext.getAttributeNames
exception:
  java.lang.IllegalArgumentException - if name is null.




getAttributeNames
public java.util.Enumeration getAttributeNames()(Code)
Returns an Enumeration containing the attribute names available within this portlet context, or an emtpy Enumeration if no attributes are available. Use the PortletContext.getAttribute method with an attribute name to get the value of an attribute. an Enumeration of attribute names
See Also:   PortletContext.getAttribute



getInitParameter
public java.lang.String getInitParameter(java.lang.String name)(Code)
Returns a String containing the value of the named context-wide initialization parameter, or null if the parameter does not exist. This method provides configuration information which may be useful for an entire "portlet application".
Parameters:
  name - a String containing the name of therequested parameter a String containing the valueof the initialization parameter, or null if the parameter does not exist.
See Also:   PortletContext.getInitParameterNames
exception:
  java.lang.IllegalArgumentException - if name is null.



getInitParameterNames
public java.util.Enumeration getInitParameterNames()(Code)
Returns the names of the context initialization parameters as an Enumeration of String objects, or an empty Enumeration if the context has no initialization parameters. an Enumeration of String objects containing the names of the contextinitialization parameters
See Also:   PortletContext.getInitParameter



getMajorVersion
public int getMajorVersion()(Code)
Returns the major version of the Portlet API that this portlet container supports. the major version
See Also:   PortletContext.getMinorVersion()



getMimeType
public String getMimeType(String file)(Code)
Returns the MIME type of the specified file, or null if the MIME type is not known. The MIME type is determined by the configuration of the portlet container and may be specified in a web application deployment descriptor. Common MIME types are text/html and image/gif.
Parameters:
  file - a String specifying the nameof a file a String specifying the MIME type of the file



getMinorVersion
public int getMinorVersion()(Code)
Returns the minor version of the Portlet API that this portlet container supports. the minor version
See Also:   PortletContext.getMajorVersion()



getNamedDispatcher
public PortletRequestDispatcher getNamedDispatcher(String name)(Code)
Returns a PortletRequestDispatcher object that acts as a wrapper for the named servlet.

Servlets (and also JSP pages) may be given names via server administration or via a web application deployment descriptor.

This method returns null if the PortletContext cannot return a PortletRequestDispatcher for any reason.
Parameters:
  name - a String specifying the nameof a servlet to be wrapped a PortletRequestDispatcher objectthat acts as a wrapper for the named servlet
See Also:   PortletRequestDispatcher




getPortletContextName
public String getPortletContextName()(Code)
Returns the name of this portlet application correponding to this PortletContext as specified in the web.xml deployment descriptor for this web application by the display-name element. The name of the web application or null if no name has been declared in the deployment descriptor.



getRealPath
public String getRealPath(String path)(Code)
Returns a String containing the real path for a given virtual path. For example, the path /index.html returns the absolute file path of the portlet container file system.

The real path returned will be in a form appropriate to the computer and operating system on which the portlet container is running, including the proper path separators. This method returns null if the portlet container cannot translate the virtual path to a real path for any reason (such as when the content is being made available from a .war archive).
Parameters:
  path - a String specifying a virtual path a String specifying the real path,or null if the transformation cannot be performed.




getRequestDispatcher
public PortletRequestDispatcher getRequestDispatcher(String path)(Code)
Returns a PortletRequestDispatcher object that acts as a wrapper for the resource located at the given path. A PortletRequestDispatcher object can be used include the resource in a response. The resource can be dynamic or static.

The pathname must begin with a slash ( / ) and is interpreted as relative to the current context root.

This method returns null if the PortletContext cannot return a PortletRequestDispatcher for any reason.
Parameters:
  path - a String specifying the pathnameto the resource a PortletRequestDispatcher objectthat acts as a wrapper for the resourceat the specified path.
See Also:   PortletRequestDispatcher




getResource
public java.net.URL getResource(String path) throws java.net.MalformedURLException(Code)
Returns a URL to the resource that is mapped to a specified path. The path must begin with a slash (/) and is interpreted as relative to the current context root.

This method allows the portlet container to make a resource available to portlets from any source. Resources can be located on a local or remote file system, in a database, or in a .war file.

The portlet container must implement the URL handlers and URLConnection objects that are necessary to access the resource.

This method returns null if no resource is mapped to the pathname.

Some containers may allow writing to the URL returned by this method using the methods of the URL class.

The resource content is returned directly, so be aware that requesting a .jsp page returns the JSP source code. Use a RequestDispatcher instead to include results of an execution.

This method has a different purpose than java.lang.Class.getResource, which looks up resources based on a class loader. This method does not use class loaders.
Parameters:
  path - a String specifyingthe path to the resource the resource located at the named path,or null if there is no resourceat that path
exception:
  MalformedURLException - if the pathname is not given in the correct form




getResourceAsStream
public java.io.InputStream getResourceAsStream(String path)(Code)
Returns the resource located at the given path as an InputStream object. The data in the InputStream can be of any type or length. The method returns null if no resource exists at the given path.

In order to access protected resources the path has to be prefixed with /WEB-INF/ (for example /WEB-INF/myportlet/myportlet.jsp). Otherwise, the direct path is used (for example /myportlet/myportlet.jsp).
Parameters:
  path - the path to the resource the input stream




getResourcePaths
public java.util.Set getResourcePaths(String path)(Code)
Returns a directory-like listing of all the paths to resources within the web application longest sub-path of which matches the supplied path argument. Paths indicating subdirectory paths end with a slash (/). The returned paths are all relative to the root of the web application and have a leading slash. For example, for a web application containing

/welcome.html
/catalog/index.html
/catalog/products.html
/catalog/offers/books.html
/catalog/offers/music.html
/customer/login.jsp
/WEB-INF/web.xml
/WEB-INF/classes/com.acme.OrderPortlet.class,

getResourcePaths("/") returns {"/welcome.html", "/catalog/", "/customer/", "/WEB-INF/"}
getResourcePaths("/catalog/") returns {"/catalog/index.html", "/catalog/products.html", "/catalog/offers/"}.

Parameters:
  path - the partial path used to match the resources, which must start with a slash a Set containing the directory listing, or null if there are no resources in the web application of which the pathbegins with the supplied path.



getServerInfo
public String getServerInfo()(Code)
Returns the name and version of the portlet container in which the portlet is running.

The form of the returned string is containername/versionnumber. the string containing at least name and version number




log
public void log(java.lang.String msg)(Code)
Writes the specified message to a portlet log file, usually an event log. The name and type of the portlet log file is specific to the portlet container.

This method mapps to the ServletContext.log method. The portlet container may in addition log this message in a portlet container specific log file.
Parameters:
  msg - a String specifying the message to be written to the log file




log
public void log(java.lang.String message, java.lang.Throwable throwable)(Code)
Writes an explanatory message and a stack trace for a given Throwable exception to the portlet log file. The name and type of the portlet log file is specific to the portlet container, usually an event log.

This method is mapped to the ServletContext.log method. The portlet container may in addition log this message in a portlet container specific log file.
Parameters:
  message - a String that describes the error or exception
Parameters:
  throwable - the Throwable error or exception




removeAttribute
public void removeAttribute(java.lang.String name)(Code)
Removes the attribute with the given name from the portlet context. After removal, subsequent calls to PortletContext.getAttribute to retrieve the attribute's value will return null.
Parameters:
  name - a String specifying the name of the attribute to be removed
exception:
  java.lang.IllegalArgumentException - if name is null.



setAttribute
public void setAttribute(java.lang.String name, java.lang.Object object)(Code)
Binds an object to a given attribute name in this portlet context. If the name specified is already used for an attribute, this method removes the old attribute and binds the name to the new attribute.

If a null value is passed, the effect is the same as calling removeAttribute().

Attribute names should follow the same convention as package names. The Java Portlet API specification reserves names matching java.*, javax.*, and sun.*.
Parameters:
  name - a String specifying the name of the attribute
Parameters:
  object - an Object representing theattribute to be bound
exception:
  java.lang.IllegalArgumentException - if name is null.




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.