Introduction to java beans, java beans, Core java, j2se, getting started with java beans programming, java to standard edition, beans in java, beans programming in java
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
This is the presentation file about inheritance in java. You can learn details about inheritance and method overriding in inheritance in java. I think it's can help your. Thank you.
PHP string function helps us to manipulate string in various ways. There are various types of string function available. Here we discuss some important functions and its use with examples.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
What is the DOM?
The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
Core DOM - standard model for all document types
XML DOM - standard model for XML documents
HTML DOM - standard model for HTML documents
The HTML DOM (Document Object Model)
When a web page is loaded, the browser creates a Document Object Model of the page.
The HTML DOM model is constructed as a tree of Objects.
With the HTML DOM, JavaScript can access and change all the elements of an HTML document.
This is the presentation file about inheritance in java. You can learn details about inheritance and method overriding in inheritance in java. I think it's can help your. Thank you.
PHP string function helps us to manipulate string in various ways. There are various types of string function available. Here we discuss some important functions and its use with examples.
JSP technology has facilitated the segregation of the work of a Web designer and a Web developer.
A Web designer can design and formulate the layout for the Web page by using HTML.
On the other hand, a Web developer working independently can use java code and other JSP specific tags to code the business logic.
The simultaneous construction of the static and dynamic content facilitates development of quality applications with increased productivity.
A bean is a reusable software component based on Sun's JavaBeans specification that can be manipulated visually in a builder tool.â
The JavaBeans technology enables vendors to create environments that make it dramatically easier to develop user interfaces for Java applications.
java, getting started with java code security, getting started with java document security, core java, j2se, introduction to code security, introduction to document security, java code and document security
Java Network Programming getting started, Getting Started with java network programming, two tier architecture, java client server programming, core java, java to standard edition, core java, Introduction to network programming in java
Overview of EJB technology.
Enterprise Java Beans (EJB) is a server-side component technology for Java EE based systems (JEE).
Beans are business logic components that implement a standard interface through which the bean is hooked into the bean container (= runtime object for bean).
A Java class implementing one of the standard bean interfaces is an Enterprise Java Bean. Beans can be accessed remotely, usually from a client tier.
The EJB standard was developed to provide a common framework for solving recurring problems in business application development like persistence, transactions,
security and runtime and lifecycle management. The EJB standard evolved greatly over time. EJB version 1 and 2 were complex and required to implement many interfaces
and exception handling in EJBs. EJB version 3 brought great simplifications and did away with interfaces by replacing these with annotations which provide greater flexibility while keeping complexity low. EJBs come in 3 different flavors: Stateless and stateful session beans and message driven beans. Entity beans of EJB version 1 and 2 were replaced by the Java Persistence API in EJB version 3.
In given slide ITVoyagers has tried to explain the concept of constructor in Java. We have used very simple language to make this silde.
We have used few examples to explain the concept.
We cover following points.
- Why we need constructor?
- Use of constructor.
- Type of constructor.
- Examples
- Rules for constructor.
- Advantages of constructor.
......................................................
Hope you will like it.
ITVoyagers is trying to make slides of topics related to IT/CS.
Please visit our blog - itvoyagers.in
Java to database connectivity for beginners, Introduction to JDBC, Getting Started with java database programming, What is java database?, core java, java to standard edition, core java, java
Java D&D, Java File Transfer, Java programming, j2se, java to standard edition, java drag and drop, D&D in java, Getting started with D&D in java, Java Data Transfer, JAVA API, Core java
Remote Method Invocation, Distributed Programming in java, Java Distributed Programming, Network Programming in JAVA, Core Java, Introduction to RMI, Getting Started with RMI, Getting Started with Remote Method Invocation, Distributed Programming, Java, J2SE
Java programming, Java Swing Programming, SWING GUI Design, desktop application, Getting Started with Swing application development in java, Introduction to GUI based programming in java, Java to standard edition, J2SE, Core Java, Swing package in java
Builder.ai Founder Sachin Dev Duggal's Strategic Approach to Create an Innova...Ramesh Iyer
Â
In today's fast-changing business world, Companies that adapt and embrace new ideas often need help to keep up with the competition. However, fostering a culture of innovation takes much work. It takes vision, leadership and willingness to take risks in the right proportion. Sachin Dev Duggal, co-founder of Builder.ai, has perfected the art of this balance, creating a company culture where creativity and growth are nurtured at each stage.
Dev Dives: Train smarter, not harder â active learning and UiPath LLMs for do...UiPathCommunity
Â
đĨ Speed, accuracy, and scaling â discover the superpowers of GenAI in action with UiPath Document Understanding and Communications Miningâĸ:
See how to accelerate model training and optimize model performance with active learning
Learn about the latest enhancements to out-of-the-box document processing â with little to no training required
Get an exclusive demo of the new family of UiPath LLMs â GenAI models specialized for processing different types of documents and messages
This is a hands-on session specifically designed for automation developers and AI enthusiasts seeking to enhance their knowledge in leveraging the latest intelligent document processing capabilities offered by UiPath.
Speakers:
đ¨âđĢ Andras Palfi, Senior Product Manager, UiPath
đŠâđĢ Lenka Dulovicova, Product Program Manager, UiPath
Key Trends Shaping the Future of Infrastructure.pdfCheryl Hung
Â
Keynote at DIGIT West Expo, Glasgow on 29 May 2024.
Cheryl Hung, ochery.com
Sr Director, Infrastructure Ecosystem, Arm.
The key trends across hardware, cloud and open-source; exploring how these areas are likely to mature and develop over the short and long-term, and then considering how organisations can position themselves to adapt and thrive.
State of ICS and IoT Cyber Threat Landscape Report 2024 previewPrayukth K V
Â
The IoT and OT threat landscape report has been prepared by the Threat Research Team at Sectrio using data from Sectrio, cyber threat intelligence farming facilities spread across over 85 cities around the world. In addition, Sectrio also runs AI-based advanced threat and payload engagement facilities that serve as sinks to attract and engage sophisticated threat actors, and newer malware including new variants and latent threats that are at an earlier stage of development.
The latest edition of the OT/ICS and IoT security Threat Landscape Report 2024 also covers:
State of global ICS asset and network exposure
Sectoral targets and attacks as well as the cost of ransom
Global APT activity, AI usage, actor and tactic profiles, and implications
Rise in volumes of AI-powered cyberattacks
Major cyber events in 2024
Malware and malicious payload trends
Cyberattack types and targets
Vulnerability exploit attempts on CVEs
Attacks on counties â USA
Expansion of bot farms â how, where, and why
In-depth analysis of the cyber threat landscape across North America, South America, Europe, APAC, and the Middle East
Why are attacks on smart factories rising?
Cyber risk predictions
Axis of attacks â Europe
Systemic attacks in the Middle East
Download the full report from here:
https://sectrio.com/resources/ot-threat-landscape-reports/sectrio-releases-ot-ics-and-iot-security-threat-landscape-report-2024/
JMeter webinar - integration with InfluxDB and GrafanaRTTS
Â
Watch this recorded webinar about real-time monitoring of application performance. See how to integrate Apache JMeter, the open-source leader in performance testing, with InfluxDB, the open-source time-series database, and Grafana, the open-source analytics and visualization application.
In this webinar, we will review the benefits of leveraging InfluxDB and Grafana when executing load tests and demonstrate how these tools are used to visualize performance metrics.
Length: 30 minutes
Session Overviewâ
-------------------------------------------
During this webinar, we will cover the following topics while demonstrating the integrations of JMeter, InfluxDB and Grafana:
- What out-of-the-box solutions are available for real-time monitoring JMeter tests?
- What are the benefits of integrating InfluxDB and Grafana into the load testing stack?
- Which features are provided by Grafana?
- Demonstration of InfluxDB and Grafana using a practice web application
To view the webinar recording, go to:
https://www.rttsweb.com/jmeter-integration-webinar
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Tobias Schneck
Â
As AI technology is pushing into IT I was wondering myself, as an âinfrastructure container kubernetes guyâ, how get this fancy AI technology get managed from an infrastructure operational view? Is it possible to apply our lovely cloud native principals as well? What benefitâs both technologies could bring to each other?
Let me take this questions and provide you a short journey through existing deployment models and use cases for AI software. On practical examples, we discuss what cloud/on-premise strategy we may need for applying it to our own infrastructure to get it to work from an enterprise perspective. I want to give an overview about infrastructure requirements and technologies, what could be beneficial or limiting your AI use cases in an enterprise environment. An interactive Demo will give you some insides, what approaches I got already working for real.
Slack (or Teams) Automation for Bonterra Impact Management (fka Social Soluti...Jeffrey Haguewood
Â
Sidekick Solutions uses Bonterra Impact Management (fka Social Solutions Apricot) and automation solutions to integrate data for business workflows.
We believe integration and automation are essential to user experience and the promise of efficient work through technology. Automation is the critical ingredient to realizing that full vision. We develop integration products and services for Bonterra Case Management software to support the deployment of automations for a variety of use cases.
This video focuses on the notifications, alerts, and approval requests using Slack for Bonterra Impact Management. The solutions covered in this webinar can also be deployed for Microsoft Teams.
Interested in deploying notification automations for Bonterra Impact Management? Contact us at sales@sidekicksolutionsllc.com to discuss next steps.
The Art of the Pitch: WordPress Relationships and SalesLaura Byrne
Â
Clients donât know what they donât know. What web solutions are right for them? How does WordPress come into the picture? How do you make sure you understand scope and timeline? What do you do if sometime changes?
All these questions and more will be explored as we talk about matching clientsâ needs with what your agency offers without pulling teeth or pulling your hair out. Practical tips, and strategies for successful relationship building that leads to closing the deal.
Transcript: Selling digital books in 2024: Insights from industry leaders - T...BookNet Canada
Â
The publishing industry has been selling digital audiobooks and ebooks for over a decade and has found its groove. Whatâs changed? What has stayed the same? Where do we go from here? Join a group of leading sales peers from across the industry for a conversation about the lessons learned since the popularization of digital books, best practices, digital book supply chain management, and more.
Link to video recording: https://bnctechforum.ca/sessions/selling-digital-books-in-2024-insights-from-industry-leaders/
Presented by BookNet Canada on May 28, 2024, with support from the Department of Canadian Heritage.
Search and Society: Reimagining Information Access for Radical FuturesBhaskar Mitra
Â
The field of Information retrieval (IR) is currently undergoing a transformative shift, at least partly due to the emerging applications of generative AI to information access. In this talk, we will deliberate on the sociotechnical implications of generative AI for information access. We will argue that there is both a critical necessity and an exciting opportunity for the IR community to re-center our research agendas on societal needs while dismantling the artificial separation between the work on fairness, accountability, transparency, and ethics in IR and the rest of IR research. Instead of adopting a reactionary strategy of trying to mitigate potential social harms from emerging technologies, the community should aim to proactively set the research agenda for the kinds of systems we should build inspired by diverse explicitly stated sociotechnical imaginaries. The sociotechnical imaginaries that underpin the design and development of information access technologies needs to be explicitly articulated, and we need to develop theories of change in context of these diverse perspectives. Our guiding future imaginaries must be informed by other academic fields, such as democratic theory and critical theory, and should be co-developed with social science scholars, legal scholars, civil rights and social justice activists, and artists, among others.
Accelerate your Kubernetes clusters with Varnish CachingThijs Feryn
Â
A presentation about the usage and availability of Varnish on Kubernetes. This talk explores the capabilities of Varnish caching and shows how to use the Varnish Helm chart to deploy it to Kubernetes.
This presentation was delivered at K8SUG Singapore. See https://feryn.eu/presentations/accelerate-your-kubernetes-clusters-with-varnish-caching-k8sug-singapore-28-2024 for more details.
GraphRAG is All You need? LLM & Knowledge GraphGuy Korland
Â
Guy Korland, CEO and Co-founder of FalkorDB, will review two articles on the integration of language models with knowledge graphs.
1. Unifying Large Language Models and Knowledge Graphs: A Roadmap.
https://arxiv.org/abs/2306.08302
2. Microsoft Research's GraphRAG paper and a review paper on various uses of knowledge graphs:
https://www.microsoft.com/en-us/research/blog/graphrag-unlocking-llm-discovery-on-narrative-private-data/
3. ADVANCE JAVA
Author Profile
ī¯ Ankit Desai
ī¯ Ph.D. Scholar, IET, Ahmedabad University
ī¯ Education: M. Tech. (C.E.), B. E. (I. T.)
ī¯ Experience: 8 years (Academic and Research)
ī¯ Research Interest: IoT, Big Data Analytics, Machine
Learning, Data Mining, Algorithms.
Classified e-Material 3
5. Advanced Java
Classified e-Material 5/17
JavaBean Concepts
ī¯ JavaBeansâĸ is a portable, platform-independent
component model written in the Java programming
language.
ī¯ JavaBean components are known as beans
ī¯ With the JavaBeans API you can create reuseable,
platform-independent components.
ī¯ Through the design mode of a builder tool, you use the
property sheet or bean customize to customize the bean
and then save (persist) your customized beans.
6. Advanced Java
Classified e-Material 6/17
Key bean concepts
ī¯ Builder tools
īŽ discover a bean's features (that is, its properties,
methods, and events) by a process known as
introspection.
ī¯ Properties are the appearance and behavior
characteristics of a bean
ī¯ Beans use events to communicate with other beans.
īŽ Listener Bean â That receives event call
īŽ Source Bean - That fires event call
ī¯ Persistence enables beans to save and restore their
state.
7. Advanced Java
Classified e-Material 7/17
Writing a Simple Bean
This section covers the following actions:
ī¯ Creating a simple bean
ī¯ Compiling the bean
ī¯ Inspecting the bean's properties and events
8. Advanced Java
Classified e-Material 8/17
ī¯ TO create a simple bean first open new file and save it as
simpleBean.java
ī¯ Place the following code in that file
import java.io.Serializable;
public class MyBean implements java.io.Serializable
{
protected int theValue;
public MyBean(){ }
public void setMyValue(int newValue)
{
theValue = newValue;
}
public int getMyValue()
{
return theValue;
}
}
9. Advanced Java
Classified e-Material 9/17
ī¯ SimpleBean extends the javax.swing.JLabel graphic
component and inherits its properties, which makes the
SimpleBean a visual component.
ī¯ Inspect Properties and Events of simpleBean.java
īŽ Following are the properties
ī¯ theValue
īŽ And events to set that properties
ī¯ settheValue();
ī¯ gettheValue();
10. Advanced Java
Classified e-Material 10/17
More on Bean Properties
The JavaBeansâĸ specification defines the following types
of bean properties:
ī¯ Simple Properties
īŽ with a single value whose changes are independent of
changes in any other property.
ī¯ Bound Properties
īŽ for which a change to the property results in a
notification being sent to some other bean.
ī¯ Constrained Properties
īŽ for which a change to the property results in
validation by another bean. The other bean may
reject the change if it is not appropriate
ī¯ Indexed Properties
īŽ that supports a range of values instead of a single
value.
11. Advanced Java
Classified e-Material 11/17
Bean properties can also be classified as follows:
ī¯ Writable â A bean property that can be changed
īŽ Standard
īŽ Expert
īŽ Preferred
ī¯ Read Only â A bean property that cannot be changed.
ī¯ Hidden â A bean property that can be changed. However,
these properties are not disclosed with the BeanInfo
class
12. Advanced Java
Classified e-Material 12/17
Simple Properties
ī¯ Simple properties can be accessed just by accessor
methods of java beans
ī¯ Normally two accessor methods available known as
īŽ getter methods
ī¯ responsible for reading a bean's properties
īŽ setter methods
ī¯ responsible for writing a beans properties
getter and setter methods form the interface between
a bean's properties and the outside world
Following is an example of simple property and its
acccessor method
13. Advanced Java
Classified e-Material 13/17
Simple Bean Property Example
public class MyBean
{
public MyBean() { }
private String title;
public String getTitle()
{
return this.title;
}
public void setTitle(String title)
{
this.title = title;
}
Creates a new instance of MyBean
Holds Value of Property âTitleâ
Getter Property for âtitleâ
Setter Property for âtitleâ
14. Advanced Java
Classified e-Material 14/17
Bound Properties
ī¯ Bound properties provide a notification service upon
being changed.
ī¯ The accessor methods for a bound property are defined
in the same way as those for simple properties
ī¯ However a bean with a bound property is required to fire
a PropertyChange method of the PropertyChangeListener
objects. This is illustrated in following figure
16. Advanced Java
Classified e-Material 16/17
Implementing Bound Property
ī¯ Import the java.beans package. This gives you access to
the PropertyChangeSupport class.
ī¯ Instantiate a PropertyChangeSupport object. This object
maintains the property change listener list and fires
property change events. You can also make your class a
PropertyChangeSupport subclass.
ī¯ Implement methods to maintain the property change
listener list.
ī¯ Modify a property's set method to fire a property change
event when the property is changed.
17. Advanced Java
Classified e-Material 17/17
java.beans.PropertyChangeEvent class
public class java.beans.PropertyChangeEvent extends
java.util.EventObject
{
PropertyChangeEvent(Object source,
String propertyName,
Object oldValue,
Object newValue);
public Object getNewValue();
public Object getOldValue();
public Object getPropagationId();
public String getPropertyName();
public void setPropagationId();
}
Constructor
Source of Event
Name of property
Old Value
New Value
18. Advanced Java
Classified e-Material 18/17
Constrained Properties
ī¯ For which a change to the property results in validation
by another bean.
ī¯ The other bean may reject the change if it is not
appropriate.
ī¯ Properties that go through this approval process are
known as constrained properties.
ī¯ They differ from other kind of properties in a way that
setter method of constrained properties throws the
java.beans.PropertyVetoException
19. Advanced Java
Classified e-Material 19/17
Implementing Constrained Property
īą Those objects that want to participate in the approval
process for a change to a constrained property must
implement the java.beans.VetoableChangeListener
interface.
īą This interface contains a method called
vetoableChange() that takes a single parameter of type
PropertyChangeEvent.
ī¯ This method may throw the
java.beans.PropertyVetoException
if it wants to reject the change.
This Process is shown in following figure
20. Advanced Java
Classified e-Material 20/17
ī¯ It's possible for the object that owns the property to reject a
change itself.
ī¯ So if a setPropertyName() method is called with an
unacceptable property value, the
java.beans.PropertyVetoException
can be thrown.
īą If the owning object does not reject the change, it must send
notifications to all registered VetoableChangeListener objects.
īą This gives any VetoableChangeListener a chance to reject the
change to property
ī¯ The event source must catch the
java.beans.PropertyVetoException.
21. Advanced Java
Classified e-Material 21/17
Property Owner
setProperty()
vetoebleChangeListnersvetoebleChangeListnersvetoebleChangeListnersvetoebleChangeListners
vetoebleChang()
Throw
propertyVetoException
if Change is required
Throw
propertyVetoException
if Change is required
22. Advanced Java
Classified e-Material 22/17
java.beans.VetoableChangeSupport
public class java.beans.VetoableChangeSupport
implements java.io.Serializable
{
public VetoableChangeSupport(Object source);
public synchronized void
addVetoableChangeListener(VetoableChangeListener l);
public void fireVetoableChange(String propertyName, Object
oldValue, Object newValue) throws
java.beans.PropertyVetoException;
public synchronized void
removeVetoableChangeListener(VetoableChangeListener l);
}
construct the object
add a vetoablechangelistener
Fire vetoable change event to any Listner
remove a vetoablechangelistener
23. Advanced Java
Classified e-Material 23/17
Indexed Properties
ī¯ An indexed property is an array of properties or objects
that supports a range of values and enables the accessor
to specify an element of a property to read or write .
ī¯ Indexed properties are very similar to arrays in
traditional Java programming.
ī¯ Indexed properties contain several elements of the same
type that can be accessed via an integer index.
ī¯ Hence the name indexed property
24. Advanced Java
Classified e-Material 24/17
ī¯ Indexed properties has multiple values so the standard
getter and setter methods aren't sufficient
ī¯ So there available two pairs of accessor methods
īŽ One pair gets and sets individual properties in the
array via an index. For example :
ī¯ public PropertyType[] getProperty();
ī¯ public void setProperty(PropertyType[] value);
īŽ While the other pair gets and sets the entire array of
properties as a single unit
ī¯ public PropertyType getProperty(int index);
ī¯ public void setProperty(int index, PropertyType
value);
25. Advanced Java
Classified e-Material 25/17
ī¯ Just as in working with standard Java arrays, it is
possible to index outside the bounds of an indexed
property array.
ī¯ When this occurs, the accessor method used to perform
the indexing typically throws an
java.lang.ArrayIndexOutOfBoundsException
runtime exception,
which is consistent with how normal Java arrays behave
when indexed out of bounds.
26. Advanced Java
Classified e-Material 26/17
Manipulating Events
ī¯ Event passing is the means by which components
communicate with each other.
ī¯ The event model by the JavaBeans architecture is
composed of three main parts:
īŽ sources,
īŽ events
īŽ listeners.
ī¯ The source of an event is the object that originates or
fires the event.
ī¯ The source must define the events it will fire,
ī¯ as well as the methods for registering listeners of
27. Advanced Java
Classified e-Material 27/17
Topics in events Handling
You learn the following major issues in this chapter:
ī¯ Event basics
ī¯ Event state objects
ī¯ Event listeners
ī¯ Event sources
ī¯ Event adapters
ī¯ Delivering events
28. Advanced Java
Classified e-Material 28/17
Event Basics
ī¯ The event-handling mechanism is directly based on the
built-in event-handling facilities provided by the Java API
ī¯ Event sources are capable of generating events
ī¯ Event listeners are designed to respond to events.
ī¯ An event is propagated from an event source to an event
listener when the event source invokes a method on the
listener.
ī¯ Beans typically play the role of event sources
29. Advanced Java
Classified e-Material 29/17
ī¯ This figure illustrate the basics of events
Event Source
Event ListenerFire Events
Register Event
Listener
Event
Object
30. Advanced Java
Classified e-Material 30/17
Event State Object
ī¯ An event object (or event state object) encapsulates the
information that is specific to an instance of an event.
ī¯ For example, an event that represents a mouse click
might contain the position of the mouse pointer
ī¯ This object is passed as the parameter to an event
notification method.
ī¯ The class java.util.EventObject is used as the base class
for all event objects. It has following events
31. Advanced Java
Classified e-Material 31/17
java.util.EventObject methods
Methods Description
public EventObject(Object
source)
The constructor for the event.
public Object getSource() Returns the object that generated
the event.
public String toString() Renders the event object in
human-readable form.
32. Advanced Java
Classified e-Material 32/17
Event Listener
ī¯ An event listener is an object that needs to be notified
when certain events occur.
ī¯ Event notifications are made through method invocations
on the listening object.
ī¯ But in order to fire an event, the event source must
know what listener method to call.
ī¯ This information is contained in an event-listener
interface that defines the methods called to fire an event
notification.
ī¯ Any class that wants to receive notifications of the event
would implement that interface.
33. Advanced Java
Classified e-Material 33/17
ī¯ All event-listener interfaces inherit from the base
interface
java.util.EventListener.
ī¯ By convention, all event-listener interfaces have names
ending in the word
Listener.
ī¯ An event-listener interface can contain any number of
methods, each one corresponding to a different event.
34. Advanced Java
Classified e-Material 34/17
ī¯ The methods that are defined in the event-listener
interfaces should conform to the standard design pattern
for event notification methods.As below..
void eventOccurenceMethodName (EventObjectType evt);
īą The eventOoccurrenceMethodName should describe
the event.
īą The EventObjectType is passed when the event is
fired.
īą And this object must be derived from the class
java.util.EventObject.
35. Advanced Java
Classified e-Material 35/17
ī¯ Event sources are objects that fire events.
ī¯ Event sources must provide a means for registering
listeners.
ī¯ Sources are required to implement a pair of registration
methods for each type of event listener they support.
ī¯ The standard design pattern for event-listener registratio
is as below
public void addListenerType( ListenerType listener);
public void removeListenerType( ListenerType listener);
Event Sources
36. Advanced Java
Classified e-Material 36/17
ī¯ The above pattern identifies the object that implements
these methods as an event source for the eventlistener
interface of type ListenerType.
ī¯ The client object invokes the addListenerType method
to register an interest in the events supported by the
associated interface.
ī¯ When the client object is no longer interested in
receiving these event notifications it invokes the
corresponding removeListenerType method.
ī¯ Multiple listeners can also be registered with a source for
a given set of events. This is called multicast event
delivery.
37. Advanced Java
Classified e-Material 37/17
Event adapters
ī¯ While using multicast event delivery as described earlier we
may face problems like..
ī¯ If a given object wanted to listen for events from a large
number of event source objects, it would have to implement
the interfaces for every one.
īŽ This may not be the best approach If only a few of the
events that are supported by the event listener interfaces
are of interest.
ī¯ Another problem occurs when an object is listening for events
from two or more objects that are sources of the same event
types.
īŽ Since an object can only implement an event listener
interface once, it would have to figure out for itself which
object was the source of the event.
38. Advanced Java
Classified e-Material 38/17
ī¯ These problems can (and often will) lead to code that is
hard to read and even harder to maintain.
ī¯ To deal with this is to introduce another objectâ
an event adapterâbetween the event source and the
event target.
ī¯ The purpose of this object is to adapt the source to the
specific needs of the target.
ī¯ Following figure shows object interaction using an
adapter
40. Advanced Java
Classified e-Material 40/17
Event Adapter Classes
ī¯ The following are some event adapter classes provided
by the Java API:
īŽ FocusAdapte
īŽ KeyAdapte
īŽ MouseAdapte
īŽ MouseMotionAdapte
īŽ WindowAdapte
41. Advanced Java
Classified e-Material 41/17
Delivering Events
ī¯ An event delivery consists of three functional parts:
īŽ An event source
īŽ An event listener
īŽ An event state object .
ī¯ Entire process begins when an event listener notifies a
source that it wants to listen to a particular event.
ī¯ It does this by calling an event listener registration
method provided by the source.
42. Advanced Java
Classified e-Material 42/17
ī¯ When this happens, the source is ready to deliver events
to the listener.
ī¯ Whenever an internal change occurs in the source that
generates an event, the source creates an event state
object describing the event and sends it out to the
listener.
ī¯ The source does this by calling one of the event
response methods defined in the listener's event listener
interface.
43. Advanced Java
Classified e-Material 43/17
Multicast event Delivery
ī¯ Multiple event listeners can be registered with and
receive events from a single event source, this type of
event delivery is known as multicast delivery.
ī¯ With multicast event delivery, event listeners can be
added and removed at will via the event listener
registration methods.
ī¯ The source is responsible for keeping track of the current
set of listeners.
ī¯ Java event delivery mechanism makes no guarantees
about the order in which listeners receive events during
a multicast delivery.
44. Advanced Java
Classified e-Material 44/17
Unicast Event Delivery
ī¯ In Unicast event delivery, only one listener is permitted
to listen to a source at a time.
ī¯ Unicast event sources can have only one registered
listener at any given time.
ī¯ The event registration methods are designed so that an
exception is thrown if additional listeners are attempted
to be added to a unicast event source with a listener
already registered.
ī¯ It's important to understand that unicast event delivery
is a more limited form of event delivery and should be
avoided whenever possible
45. Advanced Java
Classified e-Material 45/17
Problems in Event Delivery
ī¯ When event response methods throw exceptions back at
an event source
īŽ The problem is, how should an event source react to
an event response method when the listener throws
an exception?
īŽ Unfortunately, there are no hard and fast rules
governing what should happen in a situation like this.
īŽ It is entirely implementation specific, so you might
want to refer to the source documentation if you are
worried about this problem creeping up on you
46. Advanced Java
Classified e-Material 46/17
ī¯ when the set of event listeners for a source is updated
during a multicast event delivery.
īŽ In this situation it is technically possible for a listener
to be removed from the source before its event has
been delivered.
īŽ When this occurs, it is possible for an event to be
delivered to a listener that is no longer registered,
īŽ Again, there unfortunately are no strict rules about
how event sources should deal with this scenario.
47. Advanced Java
Classified e-Material 47/17
Bean Persistence
ī¯ Itâs a mechanism that enables the state of components
to be stored in a non-volatile place for later retrieval.
ī¯ The mechanism that makes persistence possible is called
serialization.
ī¯ Object serialization means converting an object into a
data stream and writing it to storage
ī¯ To support persistance beans must support serialization
by implementing
īŽ java.io.Serializable
īŽ java.io.Externalizable
48. Advanced Java
Classified e-Material 48/17
Controlling Serialization
Three ways to control serialization :
ī¯ Automatic serialization, implemented by the Serializable
interface.
ī¯ Customized serialization. Selectively exclude fields you
do not want serialized
ī¯ Customized file format, implemented by the
Externalizable interface and its two methods.
49. Advanced Java
Classified e-Material 49/17
Default Serialization: The Serializable Interface
ī¯ The Serializable interface provides automatic
serialization by using the Java Object Serialization tools.
ī¯ Serializable declares no methods
ī¯ Important points about working with the Serializable
īŽ Classes that implement Serializable must have an
access to a no-argument constructor of supertype.
īŽ Don't implement Serializable in your class if it is
already implemented in a superclass.
īŽ All fields except static and transient fields are
serialized.
50. Advanced Java
Classified e-Material 50/17
Selective Serialization Using the transient Keyword
ī¯ To exclude fields from serialization in a Serializable
object from serialization, mark the fields with the
transient modifier.
transient int status;
īą Default serialization will not serialize transient and static
fields
51. Advanced Java
Classified e-Material 51/17
Selective Serialization: writeObject and readObject
ī¯ If your serializable class contains either of the following
two methods ,then the default serialization will not take
place.
private void writeObject (java.io.ObjectOutputStream out)
throws IOException;
private void readObject(java.io.ObjectInputStream in)
throws IOException, ClassNotFoundException;
ī¯ You can control how more complex objects are serialized,
by writing your own implementations of the writeObject
and readObject methods.
52. Advanced Java
Classified e-Material 52/17
The Externalizable Interface
ī¯ Use the Externalizable interface when you need complete
control over your bean's serialization
ī¯ for example, when writing and reading a specific file
format.
ī¯ To use the Externalizable interface you need to
implement two methods:
īŽ readExternal
īŽ writeExternal
īą Classes that implement Externalizable must have a no-
argument constructor.
53. Advanced Java
Classified e-Material 53/17
Introspection
ī¯ Introspection is the automatic process of analyzing a
bean's design patterns to reveal the bean's properties,
events, and methods.
ī¯ This process controls the publishing and discovery of
bean operations and properties.
ī¯ Following are the topics to be covered
īŽ The purpose of introspection,
īŽ Introduces the Introspection API,
īŽ An example of introspection code.
54. Advanced Java
Classified e-Material 54/17
The purpose of introspection
ī¯ Introspection provides a great advantages:
īŽ Portability - Everything is done in the Java platform
so there are no platform-specific issues
īŽ Reuse â Component Reuse potential possibly exceeds
your expectations.
ī¯ By following the JavaBeans design conventions,
ī¯ Implementing the appropriate interfaces,
ī¯ Extending the appropriate classes,
55. Advanced Java
Classified e-Material 55/17
Introspection API
ī¯ The JavaBeans API architecture supplies a set of classes
and interfaces to provide introspection.
ī¯ The BeanInfo interface of the java.beans package
defines a set of methods that allow bean implementors
to provide explicit information about their beans.
ī¯ The getBeanInfo(beanName) of the Introspector class
can be used by automated environments to provide
detailed information about a bean.
ī¯ The Introspector class provides descriptor classes with
information about properties, events, and methods of a
bean.
56. Advanced Java
Classified e-Material 56/17
A hierarchy of the FeatureDescriptor classes
FeatureDescriptor
FeatureDescriptor
FeatureDescriptor
FeatureDescriptor
FeatureDescriptor
FeatureDescriptor
IndexedPropertyDescriptor
57. Advanced Java
Classified e-Material 57/17
An example of introspection code.
import java.beans.BeanInfo;
import java.beans.Introspector;
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
public class SimpleBean
{
private final String name = "SimpleBean";
private int size;
58. Advanced Java
Classified e-Material 58/17
Getter and setter Methods for Properties
public String getName()
{
return this.name;
}
public int getSize()
{
return this.size;
}
public void setSize( int size )
{
this.size = size;
}
59. Advanced Java
Classified e-Material 59/17
Main() Method to check beans
public static void main( String[] args ) throws
IntrospectionException
{
BeanInfo info = Introspector.getBeanInfo(
SimpleBean.class );
for ( PropertyDescriptor pd :
info.getPropertyDescriptors() )
System.out.println( pd.getName() );
}
}
60. Advanced Java
Classified e-Material 60/17
Summary
ī¯ It is a public class.
ī¯ It has a public parameterless constructor (though it
may have other constructors as well)
ī¯ It implements Serializable interface
ī¯ It has properties with âgetterâ and âsetterâ methods
ī¯ It has events which follow the standard Java event
model with the registration methods