Spring 5 Design Patterns Master efficient application development with patterns such as proxy singleton the template method and more 1st Edition Dinesh Rajput instant download
Spring 5 Design Patterns Master efficient application development with patterns such as proxy singleton the template method and more 1st Edition Dinesh Rajput instant download
https://ebookmeta.com/product/design-patterns-with-java-1st-
edition-olaf-musch/
https://ebookmeta.com/product/jonathan-franzen-the-comedy-of-
rage-1st-edition-philip-weinstein/
The Memory Bible: An Innovative Strategy for Keeping
Your Brain Young 2nd Edition Gary Small
https://ebookmeta.com/product/the-memory-bible-an-innovative-
strategy-for-keeping-your-brain-young-2nd-edition-gary-small/
https://ebookmeta.com/product/buck-naked-first-edition-
evangeline-anderson/
https://ebookmeta.com/product/the-essential-guide-to-coding-in-
otolaryngology-coding-billing-and-practice-management-2nd-
edition-seth-m-brown/
https://ebookmeta.com/product/a-vision-of-yemen-the-travels-of-a-
european-orientalist-and-his-native-guide-a-translation-of-
hayyim-habshush-s-travelogue-alan-verskin/
https://ebookmeta.com/product/an-introduction-to-contemporary-
islamic-philosophy-3rd-edition-mohammad-fana-i-eshkevari/
Managing Substance Use Disorder - Practitioner Guide
(Treatments That Work), 3e (Oct 25,
2019)_(0190926716)_(Oxford University Press) 3rd
Edition Daley
https://ebookmeta.com/product/managing-substance-use-disorder-
practitioner-guide-treatments-that-
work-3e-oct-25-2019_0190926716_oxford-university-press-3rd-
edition-daley/
Spring 5 Design Patterns
Dinesh Rajput
BIRMINGHAM - MUMBAI
Spring 5 Design Patterns
Copyright © 2017 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or
transmitted in any form or by any means, without the prior written permission of the
publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the
information presented. However, the information contained in this book is sold without
warranty, either express or implied. Neither the author, nor Packt Publishing, and its
dealers and distributors will be held liable for any damages caused or alleged to be caused
directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
ISBN 978-1-78829-945-9
www.packtpub.com
Credits
Through the course of writing this book, I contacted many people who helped me to clarify
many dark corners of Reactive Patterns and GoF patterns. First of all, many thanks to the
reviewer of this book, Rajeev Kumar Mohan, who is a technology consultant and trainer.
Special thanks go to Naveen Jain, who helped me create some real-world scenarios for all
GoF design patterns, as mentioned in the examples.
And of course, my thanks to my lovely wife Anamika for encouraging me and supporting
me in the writing of this book. Also thanks to my dear son Arnav for playing mobile games
with me; it made me feel refreshed at the time of writing this book.
Finally, this book took shape from the work of Packt editors, Lawrence Veigas and Karan,
who guided me through the writing process and Supriya, who joined at the last stage of the
publishing process and brought many suggestions on how to make the book better and
more useful for readers.
About the Reviewer
Rajeev Kumar Mohan has over 17 years of experience in IT, Software Development, and
Corporate Training. He has worked for various IT majors like IBM, Pentasoft, Sapient, and
Deft Infosystems. He started career as a programmer and managed various projects.
He is subject matter expert in Java, J2EE and related Frameworks, Android, and many UI
Technologies. Besides SCJP and SCWCD, Rajeev has completed four masters.
He is Organic Chemistry and Computer Science master MCA and MBA. Rajeev is
recruitment consultant and impaneled training consultant for HCL, Amdocs, Steria, TCS,
Wipro, Oracle University, IBM, CSC, Genpact , Sapient Infosys and Capgemini.
Rajeev is the founder of Greater Noida based firm SNS Infotech. He also worked for the
National Institute Of Fashion Technology [NIFT].
I would like to thank God to provide me opportunity to review the book. I would also like to
thank my kids Sana and Saina and wife Nilam for their cooperation and for encouraging
and allowing me to finish the review on time.
www.PacktPub.com
For support files and downloads related to your book, please visit www.PacktPub.com.
Did you know that Packt offers eBook versions of every book published, with PDF and
ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a
print book customer, you are entitled to a discount on the eBook copy. Get in touch with us
at [email protected] for more details.
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a
range of free newsletters and receive exclusive discounts and offers on Packt books and
eBooks.
https://www.packtpub.com/mapt
Get the most in-demand software skills with Mapt. Mapt gives you full access to all Packt
books and video courses, as well as industry-leading tools to help you plan your personal
development and advance your career.
Why subscribe?
Fully searchable across every book published by Packt
Copy and paste, print, and bookmark content
On demand and accessible via a web browser
Customer Feedback
Thanks for purchasing this Packt book. At Packt, quality is at the heart of our editorial
process. To help us improve, please leave us an honest review on this book's Amazon page
at https://www.amazon.com/dp/1788299450.
If you'd like to join our team of regular reviewers, you can email us at
[email protected]. We award our regular reviewers with free eBooks and
videos in exchange for their valuable feedback. Help us be relentless in improving our
products!
I want to dedicate this book to my parents, my lovely wife, and my dear son Arnav.
[ ii ]
UML structure for the Proxy design pattern 95
Implementing the Proxy design pattern 96
Proxy pattern in the Spring Framework 97
Behavioral design patterns 97
Chain of Responsibility design pattern 98
Chain of Responsibility pattern in the Spring Framework 99
Command design pattern 99
Command design pattern in the Spring Framework 100
Interpreter Design pattern 101
Interpreter design pattern in the Spring Framework 102
Iterator Design Pattern 102
Iterator design pattern in the Spring Framework 103
Observer pattern in the Spring Framework 106
Template Design Pattern 106
JEE design patterns 107
Summary 109
Chapter 4: Wiring Beans using the Dependency Injection Pattern 110
The dependency injection pattern 112
Solving problems using the dependencies injection pattern 112
Without dependency injection 113
With dependency injection pattern 116
Types of dependency injection patterns 118
Constructor-based dependency injection pattern 118
Setter-based dependency injection 120
Configuring the dependency injection pattern with Spring 123
Dependency injection pattern with Java-based configuration 124
Creating a Java configuration class - AppConfig.java 125
Declaring Spring beans into configuration class 125
Injecting Spring beans 126
Best approach to configure the dependency injection pattern with Java 127
Dependency injection pattern with XML-based configuration 128
Creating an XML configuration file 129
Declaring Spring beans in an XML file 129
Injecting Spring beans 130
Using constructor injection 130
Using setter injection 131
Dependency injection pattern with Annotation-based configuration 133
What are Stereotype annotations? 134
Creating auto searchable beans using Stereotype annotations 135
Searching beans using component scanning 137
Annotating beans for autowiring 139
Using @Autowired with setter method 141
Using @Autowired with the fields 141
The Autowiring DI pattern and disambiguation 142
[ iii ]
Resolving disambiguation in Autowiring DI pattern 143
Implementing the Abstract Factory Pattern in Spring (FactoryBean interface) 144
Implementation of FactoryBean interface in Spring 145
Sample implementation of FactoryBean interface 145
Best practices for configuring the DI pattern 147
Summary 149
Chapter 5: Understanding the Bean Life Cycle and Used Patterns 150
The Spring bean life cycle and its phases 151
The initialization phase 152
Creating the application context from configuration 152
Load bean definitions 154
Initializing bean instances 157
Customizing beans using a BeanPostProcessor 158
The Initializer extension point 160
The Use phase of beans 163
Implementing the Decorator and Proxy patterns in Spring using Proxies 164
The destruction phase of the beans 165
Understanding bean scopes 168
The singleton bean scope 169
The prototype bean scope 170
The session bean scope 170
The request bean scope 171
Other scopes in Spring 171
Custom scopes 171
Creating custom scopes 171
Summary 174
Chapter 6: Spring Aspect Oriented Programming with Proxy and
Decorator pattern 175
Proxy pattern in Spring 177
Proxying classes using Decorator pattern in Spring 177
What are cross-cutting concerns? 178
What is Aspect-Oriented Programming? 179
Problems resolved by AOP 180
Code tangling 180
Code scattering 181
How AOP Works to solve problems 183
Core AOP terminology and concepts 184
Advice 184
Join Point 186
Pointcut 186
Aspect 186
[ iv ]
Weaving 186
Defining pointcuts 187
Writing pointcuts 188
Creating aspects 190
Define aspects using Annotation 191
Implementing Advice 193
Advice type - Before 193
Before Advice example 193
Advice Types: After Returning 194
After Returning Advice example 195
Advice Types: After Throwing 195
After Throwing Advice example 196
Advice Types: After 197
After Advice example 197
Advice Types - Around 198
Around Advice example 198
Define aspects using XML configuration 200
Understanding AOP proxies 202
Summary 204
Chapter 7: Accessing a Database with Spring and JDBC Template
Patterns 205
The best approach to designing your data-access 206
The resource management problem 209
Implementing the template design pattern 210
Problems with the traditional JDBC 211
Solving problems with Spring's JdbcTemplate 212
Configuring the data source and object pool pattern 214
Configuring a data source using a JDBC driver 215
Configuring the data source using pool connections 217
Implementing the Builder pattern to create an embedded data source 219
Abstracting database access using the DAO pattern 220
The DAO pattern with the Spring Framework 221
Working with JdbcTemplate 222
When to use JdbcTemplate 222
Creating a JdbcTemplate in an application 223
Implementing a JDBC-based repository 223
Jdbc callback interfaces 225
Creating a RowMapper class 225
Implementing RowCallbackHandler 226
Implementing ResultSetExtractor 227
Best practices for Jdbc and configuring JdbcTemplate 229
[v]
Exploring the Variety of Random
Documents with Different Content
"I am going to see Amory," he said. "I have heard some news he will
consider bad. The Westoria affair has been laid aside, and will not be
acted upon this session, if at all. It is said that Blundel heard
something he did not like, and interfered."
"And you think Mr. Amory will be very much disappointed?" said
Agnes.
"I am afraid so," answered Tredennis.
"And yet," said Agnes, "it isn't easy to see why it should be of so
much importance to him."
"He has become interested in it," said Mrs. Merriam. "That is the
expression, isn't it? It is my opinion that it would be better for him if
he were less so. I have seen that kind of thing before. It is like being
bitten by a tarantula."
She was not favorably inclined toward Richard. His sparkling moods
did not exhilarate her, and she had her private theories concerning
his character. Tredennis she was very fond of; few of his moods
escaped her bright eyes; few of the changes in him were lost upon
her. When he went away this evening she spoke of him to Agnes and
Arbuthnot.
"If that splendid fellow does not improve," she said, "he will begin to
grow old in his prime. He is lean and gaunt; his eyes are dreary; he
is beginning to have lines on his forehead and about his mouth. He
is enduring something. I should be glad to be told what it is."
"Whatever he endured," said Agnes, "he would not tell people. But I
think 'enduring' is a very good word."
"How long have you known him?" Mrs. Merriam asked of Arbuthnot.
"Since the evening after his arrival in Washington on his return from
the West," was the reply.
"Was he like this then?" rather sharply.
Arbuthnot reflected.
"I met him at a reception," he said, "and he was not Washingtonian
in his manner. My impression was that he would not enjoy our
society, and that he would finally despise us; but he looked less
fagged then than he does now. Perhaps he begins to long for his
daily Pi-ute. There are chasms which an effete civilization does not
fill."
"You guess more than you choose to tell," was Mrs. Merriam's
inward thought. Aloud she said:
"He is the finest human being it has been my pleasure to meet. He is
the natural man. If I were a girl again I think I should make a hero
of him, and be unhappy for his sake."
"It would be easy to make a hero of him," said Agnes.
"Very!" responded Arbuthnot. "Unavoidable, in fact." And he laid
upon the table the bit of hyacinth he had picked up in the boat and
brought home with him. "If I carry it away," was his private thought,
"I shall fall into the habit of sitting and weakening my mind over it.
It is weak enough already." But he knew, at the same time, that
Colonel Tredennis had done something toward assisting him to form
the resolution. "A trivial masculine vanity," he thought, "not
unfrequently strengthens one's position."
In the meantime Tredennis went to Amory. He found him in the
room which was, in its every part, so strong a reminder of Bertha. It
wore a desolate look, and Amory had evidently been walking up and
down it, pushing chairs and footstools aside carelessly, when he
found them in his way. He had thrown himself, at last, into Bertha's
own special easy-chair, and leaned back in it, with his hands thrown
out over its padded arms. He had plainly not slept well the night
before, and his dress had a careless and dishevelled look, very
marked in its contrast with the customary artistic finish of his attire.
He sprang up when he saw Tredennis, and began to speak at once.
"I say!" he exclaimed, "this is terrible!"
"You have been disappointed," said Tredennis.
"I have been rui"—he checked himself; "disappointed isn't the
word," he ended. "The whole thing has been laid aside—laid aside—
think of it! as if it were a mere nothing; an application for a two-
penny half-penny pension! Great God! what do the fellows think they
are dealing with?"
"Who do you think is to blame?" said the colonel, stolidly.
"Blundel, by Jove!—Blundel, that fool and clown!" and he flung
himself about the room, mumbling his rage and irritation.
"It is not the first time such a thing has happened," said Tredennis,
"and it won't be the last. If you continue to interest yourself in such
matters you will find that out, as others have done before you. Take
my advice, and give it up from this hour."
Amory wheeled round upon him.
"Give it up!" he cried, "I can't give it up, man! It is only laid aside for
the time being. Heaven and earth shall be moved next year—Heaven
and earth! The thing won't fail—it can't fail—a thing like that; a thing
I have risked my very soul on!"
He dashed his hand through his tumbled hair and threw himself into
the chair again, quite out of breath.
"Ah, confound it!" he exclaimed, "I am too excitable! I am losing my
hold on myself."
Tredennis rose from his seat, feeling some movement necessary. He
stood and looked down at the floor. As he gazed up at him Amory
entered a fretful mental protest against his size and his air of being
able to control himself. He was plainly deep in thought even when he
spoke, for his eyes did not leave the floor.
"I suppose," he said, "this is really no business of mine. I wish it
was."
"What do you mean?" said Amory.
Tredennis looked up.
"If it were my business I would know more about it," he said.—"I
would know what you mean, and how deep you have gone into this
—this accursed scheme."
The last two words had a sudden ring of intensity in their sound,
which affected Amory tremendously. He sprang up again and began
to pace the floor.
"Nothing ever promised so well," he said, "and it will turn out all
right in the end—it must! It is the delay that drives one wild. It will
be all right next season—when Bertha is here."
"What has she to do with it?" demanded Tredennis.
"Nothing very much," said Amory, restively; "but she is effective."
"Do you mean that you are going to set her to lobbying?"
"Why should you call it that? I am not going to set her at anything.
She has a good effect, that is all. Planefield swears that if she had
stayed at home and taken Blundel in hand he would not have failed
us."
Tredennis looked at him stupefied. He could get no grasp upon him.
He wondered if a heavy mental blow would affect him. He tried it in
despair.
"Do you know," he said, slowly, "what people are beginning to say
about Planefield?"
"They are always saying something of Planefield. He is the kind of
man who is always spoken of."
"Then," said Tredennis, "there is all the more reason why his name
should not be connected with that of an innocent woman."
"What woman has been mentioned in connection with him?"
"It has been said more than once that he is in love with—your wife,
and that his infatuation is used to advance your interests."
Richard stopped on his walk.
"Then it is a confoundedly stupid business," he said, angrily. "If she
hears it she will never speak to him again. Perhaps she has heard it;
perhaps that was why she insisted on going away. I thought there
was something wrong at the time."
"May I ask," said Tredennis, "how it strikes you?"
"Me!" exclaimed Richard. "As the most awkward piece of business in
the world, and as likely to do me more harm than anything else
could."
He made a graceful, rapid gesture of impatience.
"Everything goes against me!" he said. "She never liked him from
the first, and if she has heard this she will never be civil to him
again, or to any of the rest of them. And, of course, she is an
influence, in a measure; what clever woman is not? And why should
she not use her influence in one way as well as another? If she were
a clergyman's wife she would work hard enough to gain favors. It is
only a trifle that she should make an effort to be agreeable to men
who will be pleased by her civility. She would do it if there were
nothing to be gained. Where are you going? What is the matter?" for
Tredennis had walked to the table and taken his hat.
"I am going into the air," he answered; "I am afraid I cannot be of
any use to you to-night. My mind is not very clear just now. I must
have time to think."
"You look pale," said Amory, staring at him. "You look ghastly. You
have not been up to the mark for months. I have seen that.
Washington does not agree with you."
"That is it," was Tredennis' response. "Washington does not agree
with me."
And he carried his hat and his pale and haggard countenance out
into the night, and left Richard gazing after him, feverish, fretted,
thwarted in his desire to pour forth his grievances and defend
himself, and also filled with baffled amazement at his sudden
departure.
CHAPTER XXXI.
Mrs. Amory did not receive on New Year's day. The season had well
set in before she arrived in Washington. One morning in January
Mrs. Sylvestre, sitting alone, reading, caught sight of the little coupé
as it drew up before the carriage-step, and, laying aside her book,
reached the parlor door in time to meet Bertha as she entered it.
She took both her hands and drew her toward the fire, still holding
them.
"Why did I not know you had returned?" she said. "When did you
arrive?"
"Last night," Bertha answered. "You see I come to you early."
It was a cold day and she was muffled in velvet and furs. She sat
down, loosened her wrap and let it slip backward, and as its
sumptuous fulness left her figure it revealed it slender to fragility,
and showed that the outline of her cheek had lost all its roundness.
She smiled faintly, meeting Agnes' anxious eyes.
"Don't look at me," she said. "I am not pretty. I have been ill. You
heard I was not well in Newport? It was a sort of low fever, and I am
not entirely well yet. Malaria, you know, is always troublesome. But
you are very well?"
"Yes, I am well," Agnes replied.
"And you begin to like Washington again?"
"I began last winter."
"How did you enjoy the spring? You were here until the end of
June."
"It was lovely."
"And now you are here once more, and how pretty everything about
you is!" Bertha said, glancing around the room. "And you are ready
to be happy all winter until June again. Do you know, you look
happy. Not excitably happy, but gently, calmly happy, as if the
present were enough for you."
"It is," said Agnes, "I don't think I want any future."
"It would be as well to abolish it if one could," Bertha answered;
"but it comes—it comes!"
She sat and looked at the fire a few seconds under the soft shadow
of her lashes, and then spoke again.
"As for me," she said, "I am going to give dinner-parties to Senator
Planefield's friends."
"Bertha!" exclaimed Agnes.
"Yes," said Bertha, nodding gently. "It appears somehow that
Richard belongs to Senator Planefield, and, as I belong to Richard,
why, you see"—
She ended with a dramatic little gesture, and looked at Agnes once
more.
"It took me some time to understand it," she said. "I am not quite
sure that I understand it quite thoroughly even now. It is a little
puzzling, or, perhaps, I am dull of comprehension. At all events,
Richard has talked to me a great deal. It is plainly my duty to be
agreeable and hospitable to the people he wishes to please and
bring in contact with each other."
"And those people?" asked Agnes.
"They are political men: they are members of committees, members
of the House, members of the Senate; and their only claim to
existence in our eyes is that they are either in favor of or opposed to
a certain bill not indirectly connected with the welfare of the owners
of Westoria lands."
"Bertha," said Agnes, quickly, "you are not yourself."
"Thank you," was the response, "that is always satisfactory, but the
compliment would be more definite if you told me who I happened
to be. But I can tell you that I am that glittering being, the female
lobbyist. I used to wonder last winter if I was not on the verge of it;
but now I know. I wonder if they all begin as innocently as I did,
and find the descent—isn't it a descent?—as easy and natural. I feel
queer, but not exactly disreputable. It is merely a matter of being a
dutiful wife and smiling upon one set of men instead of another. Still,
I am slightly uncertain as to just how disreputable I am. I was
beginning to be quite reconciled to my atmosphere until I saw
Colonel Tredennis, and I confess he unsettled my mind and
embarrassed me a little in my decision."
"You have seen him already?"
"Accidentally, yes. He did not know I had returned, and came to see
Richard. He is quite intimate with Richard now. He entered the
parlor and found me there. I do not think he was glad to see me. I
left him very soon."
She drew off her glove, and smoothed it out upon her knee, with a
thin and fragile little hand upon which the rings hung loosely. Agnes
bent forward and involuntarily laid her own hand upon it.
"Dear," she said.
Bertha hurriedly lifted her eyes.
"What I wish to say," she said, "was that the week after next we
give a little dinner to Senator Blundel, and I wanted to be sure I
might count on you. If you are there—and Colonel Tredennis—you
will give it an unprofessional aspect, which is what we want. But
perhaps you will refuse to come?"
"Bertha," said Mrs. Sylvestre, "I will be with you at any time—at all
times—you wish for or need me."
"Yes," said Bertha, reflecting upon her a moment, "I think you
would."
She got up and kissed her lightly and without effusion, and then
Agnes rose, too, and they stood together.
"You were always good," Bertha said. "I think life has made you
better instead of worse. It is not so always. Things are so different—
everything seems to depend upon circumstances. What is good in
me would be far enough from your standards to be called
wickedness."
She paused abruptly, and Agnes felt that she did so to place a check
upon herself; she had seen her do it before. When she spoke again
it was in an entirely different tone, and the remaining half-hour of
her visit was spent in the discussion of every-day subjects. Agnes
listened, and replied to her with a sense of actual anguish. She could
have borne better to have seen her less self-controlled; or she
fancied so, at least. The summer had made an alteration in her,
which it was almost impossible to describe. Every moment revealed
some new, sad change in her, and yet she sat and talked
commonplaces, and was bright, and witty, and epigrammatic until
the last.
"When we get our bill through," she said, with a little smile, just
before her departure, "I am to go abroad for a year,—for two, for
three, if I wish. I think that is the bribe which has been offered me.
One must always be bribed, you know."
As she stood at the window watching the carriage drive away, Agnes
was conscious of a depression which was very hard to bear. The
brightness of her own atmosphere seemed to have become heavy,—
the sun hid itself behind the drifting, wintry clouds,—she glanced
around her room with a sense of dreariness. Something carried her
back to the memories which were the one burden of her present life.
"Such grief cannot enter a room and not leave its shadow behind it,"
she said. And she put her hand against the window-side, and leaned
her brow upon it sadly. It was curious, she thought, the moment
after, that the mere sight of a familiar figure should bring such a
sense of comfort with it as did the sight of the one she saw
approaching. It was that of Laurence Arbuthnot, who came with a
business communication for Mrs. Merriam, having been enabled, by
chance, to leave his work for an hour. He held a roll of music in one
hand and a bunch of violets in the other, and when he entered the
room was accompanied by the fresh fragrance of the latter offering.
Agnes made a swift involuntary movement toward him.
"Ah!" she said, "I could scarcely believe that it was you."
He detected the emotion in her manner and tone at once.
"Something has disturbed you," he said. "What is it?"
"I have seen Bertha," she answered, and the words had a sound of
appeal in them, which she herself no more realized or understood
than she comprehended the impulse which impelled her to speak.
"She has been here! She looks so ill—so worn. Everything is so sad!
I"—
She stopped and stood looking at him.
"Must I go away?" he said, quietly. "Perhaps you would prefer to be
alone. I understand what you mean, I think."
"Oh, no!" she said, impulsively, putting out her hand. "Don't go. I am
unhappy. It was—it was a relief to see you."
And when she sank on the sofa, he took a seat near her and laid the
violets on her lap, and there was a faint flush on his face.
The little dinner, which was the first occasion of Senator Blundel's
introduction to the Amory establishment, was a decided success.
"We will make it a success," Bertha had said. "It must be one." And
there was a ring in her voice which was a great relief to her
husband.
"It will be one," he said. "There is no fear of your failing when you
begin in this way." And his spirits rose to such an extent that he
became genial and fascinating once more, and almost forgot his late
trials and uncertainties. He had always felt great confidence in
Bertha.
On the afternoon of the eventful day Bertha did not go out. She
spent the hours between luncheon and the time for dressing with
her children. Once, as he passed the open door of the nursery,
Richard saw her sitting upon the carpet, building a house of cards,
while Jack, and Janey, and Meg sat about her enchanted. A braid of
her hair had become loosened and hung over her shoulder; her
cheeks were flushed by the fire; she looked almost like a child
herself, with her air of serious absorbed interest in the frail structure
growing beneath her hands.
"Won't that tire you?" Richard asked.
She glanced up with a smile.
"No," she said, "it will rest me."
He heard her singing to them afterward, and later, when she went to
her dressing-room, he heard the pretty lullaby die away gradually as
she moved through the corridor.
When she appeared again she was dressed for dinner, and came in
buttoning her glove, and at the sight of her he uttered an
exclamation of pleasure.
"What a perfect dress!" he said. "What is the idea? There must be
one."
She paused and turned slowly round so that he might obtain the full
effect.
"You should detect it," she replied. "It is meant to convey one."
"It has a kind of dove-like look," he said.
She faced him again.
"That is it," she said, serenely. "In the true artist spirit, I have attired
myself with a view to expressing the perfect candor and simplicity of
my nature. Should you find it possible to fear or suspect me of
ulterior motives—if you were a senator, for instance?"
"Ah, come now!" said Richard, not quite so easily, "that is nonsense!
You have no ulterior motives."
She opened her plumy, dove-colored fan and came nearer him.
"There is nothing meretricious about me," she said.
"I am softly clad in dove color; a few clusters of pansies adorn me; I
am covered from throat to wrists; I have not a jewel about me.
Could the effect be better?"
"No, it could not," he replied, but suddenly he felt a trifle
uncomfortable again, and wondered what was hidden behind the
inscrutable little gaze she afterwards fixed upon the fire.
But when Blundel appeared, which he did rather early, he felt
relieved again. Nothing could have been prettier than her greeting of
him, or more perfect in its attainment of the object of setting him at
his ease. It must be confessed that he was not entirely at his ease
when he entered, his experience not having been of a nature to
develop in him any latent love for general society. He had fought too
hard a fight to leave him much time to know women well, and his
superficial knowledge of them made him a trifle awkward, as it
occasionally renders other men astonishingly bold. In a party of men
all his gifts displayed themselves; in the presence of women he was
afraid that less substantial fellows had the advantage of him,—men
who could not tell half so good a story or make half so exhilarating a
joke. As to this special dinner he had not been particularly anxious
to count himself among the guests, and was not very certain as to
how Planefield had beguiled him into accepting the invitation.
But ten minutes after he had entered the room he began to feel
mollified. Outside the night was wet and unpleasant, and not
calculated to improve a man's temper; the parlors glowing with fire-
light and twinkling wax candles were a vivid and agreeable contrast
to the sloppy rawness. The slender, dove-colored figure, with its soft,
trailing draperies, assumed more definitely pleasant proportions, and
in his vague, inexperienced, middle-aged fashion he felt the effect of
it. She had a nice way, this little woman, he decided; no nonsense or
airs and graces about her: an easy manner, a gay little laugh. He did
not remember exactly afterward what it was she said which first
wakened him up, but he found himself laughing and greatly amused,
and when he made a witticism he felt he had reason to be proud of,
the gay little peal of laughter which broke forth in response had the
most amazingly exhilarating effect upon him, and set him upon his
feet for the evening. Women seldom got all the flavor of his jokes.
He had an idea that some of them were a little afraid of them and of
him, too. The genuine mirth in Bertha's unstudied laughter was like
wine to him, and was better than the guffaws of a dozen men,
because it had a finer and a novel flavor. After the joke and the
laugh the ice was melted, and he knew that he was in the humor to
distinguish himself.
Planefield discovered this the moment he saw him, and glanced at
Richard, who was brilliant with good spirits.
"She's begun well," he said, when he had an opportunity to speak to
him. "I never saw him in a better humor. She's pleased him
somehow. Women don't touch him usually."
"She will end better," said Richard. "He pleases her."
He did not displease her, at all events. She saw the force and humor
of his stalwart jokes, and was impressed by the shrewd, business-
like good-nature which betrayed nothing. When he began to enjoy
himself she liked the genuineness of his enjoyment all the more
because it was a personal matter with him, and he seemed to revel
in it.
"He enjoys himself," was her mental comment, "really himself, not
exactly the rest of us, except as we stimulate him, and make him
say good things."
Among the chief of her gifts had always been counted the power of
stimulating people, and making them say their best things, and she
made the most of this power now. She listened with her brightest
look, she uttered her little exclamations of pleasure and interest at
exactly the right moment, and the gay ring of her spontaneous
sounding laugh was perfection. Miss Varien, who was one of her
guests, sat and regarded her with untempered admiration.
"Your wife," she said to Amory, in an undertone, "is simply
incomparable. It is not necessary to tell you that, of course; but it
strikes me with fresh force this evening. She really seems to enjoy
things. That air of gay, candid delight is irresistible. It makes her
seem to that man like a charming little girl—a harmless, bright,
sympathetic little girl. How he likes her!"
When she went in to dinner with him, and he sat by her side, he
liked her still more. He had never been in better spirits in his life; he
had never said so many things worth remembering; he had never
heard such sparkling and vivacious talk as went on round this
particular table. It never paused or lagged. There was Amory, all
alight and stirred by every conversational ripple which passed him;
there was Miss Varien, scintillating and casting off showers of sparks
in the prettiest and most careless fashion; there was Laurence
Arbuthnot, doing his share without any apparent effort, and
appreciating his neighbors to the full; there was Mrs. Sylvestre, her
beautiful eyes making speech almost superfluous, and Mrs. Merriam,
occasionally casting into the pool some neatly weighted pebble,
which sent its circles to the shore; and in the midst of the
coruscations Blundel found himself, somehow, doing quite his
portion of the illumination. Really these people and their dinner-
party pleased him wonderfully well, and he was far from sorry that
he had come, and far from sure that he should not come again if he
were asked. He was shrewd enough, too, to see how much the
success of everything depended upon his own little companion at
the head of the table, and, respecting success beyond all things,
after the manner of his kind, he liked her all the better for it. There
was something about her which, as Miss Varien had said, made him
feel that she was like a bright, sympathetic little girl, and
engendered a feeling of fatherly patronage which was entirely
comfortable. But, though she rather led others to talk than talked
herself, he noticed that she said a sharp thing now and then; and he
liked that, too, and was greatly amused by it. He liked women to be
sharp, if they were not keen enough to interfere with masculine
prerogatives. There was only one person in the company he did not
find exhilarating, and that was a large, brown-faced fellow, who sat
next to Mrs. Merriam, and said less than might have been expected
of him, though, when he spoke, his remarks were well enough in
their way. Blundel mentioned him afterward to Bertha when they
returned to the parlor.
"That colonel, who is he?" he asked her. "I didn't catch his name
exactly. Handsome fellow; but he'd be handsomer if"—
"It is the part of wisdom to stop you," said Bertha, "and tell you that
he is a sort of cousin of mine, and his perfections are such as I
regard with awe. His name is Colonel Tredennis, and you have read
of him in the newspapers."
"What!" he exclaimed, turning his sharp little eyes upon Tredennis,
—"the Indian man? I'm glad you told me that. I want to talk to him."
And, an opportunity being given him, he proceeded to do so with
much animation, ruffling his stiff hair up at intervals in his interest,
his little eyes twinkling like those of some alert animal.
He left the house late and in the best of humors. He had forgotten
for the time being all questions of bills and subsidies. Nothing had
occurred to remind him of such subjects. Their very existence
seemed a trifle problematical, or, rather, perhaps it seemed desirable
that it should be so.
"I feel," he said to Planefield, as he was shrugging himself into his
overcoat, "as if I had rather missed it by not coming here before."
"You were asked," answered Planefield.
"So I was," he replied, attacking the top button of the overcoat.
"Well, the next time I am asked I suppose I shall come."
Then he gave his attention to the rest of the buttons.
"A man in public life ought to see all sides of his public," he said,
having disposed of the last one. "Said some good things, didn't
they? The little woman isn't without a mind of her own, either. When
is it she receives?"
"Thursdays," said Planefield.
"Ah, Thursdays."
And they went out in company.
Her guests having all departed, Bertha remained for a few minutes
in the parlor. Arbuthnot and Tredennis went out last, and as the door
closed upon them she looked at Richard.
"Well?" she said.
"Well!" exclaimed Richard. "It could not have been better!"
"Couldn't it?" she said, looking down a little meditatively.
"No," he responded, with excellent good cheer, "and you see how
simple it was, and—and how unnecessary it is to exaggerate it and
call it by unpleasant names. What we want is merely to come in
contact with these people, and show them how perfectly harmless
we are, and that when the time comes they may favor us without
injury to themselves or any one else. That's it in a nutshell."
"We always say 'us,' don't we?" said Bertha,—"as if we were part-
proprietors of the Westoria lands ourselves. It is a little confusing,
don't you think so?"
She paused and looked up with one of her sudden smiles.
"Still I don't feel exactly sure that I have been—but no, I am not to
call it lobbying, am I? What must I call it? It really ought to have a
name."
"Don't call it anything," said Richard, faintly conscious of his
dubiousness again.
"Why, what a good idea!" she answered. "What a good way of
getting round a difficulty—not to give it a name! It almost obliterates
it, doesn't it? It is an actual inspiration. We won't call it anything.
There is so much in a name—too much, on the whole, really. But—
without giving it a name—I have behaved pretty well and advanced
our—your—whose interests?"
"Everybody's," he replied, with an effort at lightness. "Mine
particularly. I own that my view of the matter is a purely selfish one.
There is a career before me, you know, if all goes well."
He detected at once the expression of gentleness which softened
her eyes as she watched him.
"You always wanted a career, didn't you?" she said.
"It isn't pleasant," he said, "for a man to know that he is not a
success."
"If I can give you your career," she said, "you shall have it, Richard.
It is a simpler thing than I thought, after all." And she went upstairs
to her room, stopping on the way to spend a few minutes in the
nursery.
CHAPTER XXXII.
The professor sat in his favorite chair by his library fire, an open
volume on his knee, and his after-dinner glass of wine, still
unfinished, on the table near him. He had dined a couple of hours
ago with Mr. Arbuthnot, who had entertained him very agreeably
and had not long since left him to present himself upon some social
scene.
It was of his departed guest that he was thinking as he pondered,
and of certain plans he had on hand for his ultimate welfare, and his
thoughts so deeply occupied him that he did not hear the sound of
the door-bell, which rang as he sat, nor notice any other sound until
the door of the room opened and some one entered. He raised his
head and looked around then, uttering a slight ejaculation of
surprise.
"Why, Bertha!" he said. "My dear! This is unexpected."
He paused and gave her one of his gently curious looks. She had
thrown her cloak off as she came near him, and something in her
appearance attracted his attention.
"My dear," he said, slowly, "you look to-night as you did years ago. I
am reminded of the time when Philip first came to us. I wonder
why?"
There was a low seat near his side, and she came and took it.
"It is the dress," she said. "I was looking over some things I had laid
aside, and found it. I put it on for old acquaintance' sake. I have
never worn it since then. Perhaps I hoped it would make me feel like
a girl again."
Her tone was very quiet, her whole manner was quiet; the dress was
simplicity itself. A little lace kerchief was knotted about her throat.
"That is a very feminine idea," remarked the professor, seeming to
give it careful attention. "Peculiarly feminine, I should say. And—
does it, my dear?"
"Not quite," she answered. "A little. When I first put it on and stood
before the glass I forgot a good many things for a few moments,
and then, suddenly, I heard the children's voices in the nursery, and
Richard came in, and Bertha Herrick was gone. You know I was
Bertha Herrick when I wore this—Bertha Herrick, thinking of her first
party."
"Yes, my dear," he responded, "I—I remember."
There were a few moments of silence, in which he looked
abstractedly thoughtful, but presently he bestirred himself.
"By the by," he said, "that reminds me. Didn't I understand that
there was a great party somewhere to-night? Mr. Arbuthnot left me
to go to it, I think. I thought there was a reason for my surprise at
seeing you. That was it. Surely you should have been at the great
party instead of here."
"Well," she replied, "I suppose I should, but for some curious
accident or other—I don't know what the accident is or how it
happened—I should have had an invitation—of course if it had
chanced to reach me; but something has occurred to prevent it
doing so, I suppose. Such things happen, you know. To all intents
and purposes I have not been invited, so I could not go. And I am
very glad. I would rather be here."
"I would rather have you here," he returned, "if such seclusion
pleases you. But I can hardly imagine, my dear, how the party"—
She put her hand on his caressingly.
"It cannot be an entire success," she said. "It won't, in my absence;
but misfortunes befall even the magnificent and prosperous, and the
party must console itself. I like to be here—I like very much to be
here."
He glanced at her gray dress again.
"Bertha Herrick would have preferred the party," he remarked.
"Bertha Amory is wiser," she said. "We will be quiet together—and
happy."
They were very quiet. The thought occurred to the professor several
times during the evening. She kept her seat near him, and talked to
him, speaking, he noticed, principally of her children and of the past;
the time she had spent at home before her marriage seemed to be
present in her mind.
"I wonder," she said once, thoughtfully, "what sort of girl I was? I
can only remember that I was such a happy girl! Do you remember
that I was a specially self-indulgent or frivolous one? But I am afraid
you would not tell me, if you did."
"My dear," he said, in response, "you were a natural, simple, joyous
creature, and a great pleasure to us."
She gave his hand a little pressure.
"I can remember that you were always good to me," she said. "I
used to think you were a little curious about me, and wondered what
I would do in the future. Now it is my turn to wonder if I am at all
what you thought I would be?"
He did not reply at once, and then spoke slowly.
"There seemed so many possibilities," he said. "Yes; I thought it
possible that you might be—what you are."
It was as he said this that there returned to his mind the thought
which had occupied it before her entrance. He had been thinking
then of something he wished to tell her, before she heard it from
other quarters, and which he felt he could tell her at no more fitting
time than when they were alone. It was something relating to
Laurence Arbuthnot, and, curiously enough, she paved the way for it
by mentioning him herself.
"Did you say Laurence was here to-night?" she asked.
"Yes," he replied, "he was so good as to dine with me."
"He would say that you were so good as to invite him," she said. "He
is very fond of coming here."
"I should miss him very much," he returned, "if he should go away."
She looked up quickly, attracted by his manner.
"But there is no likelihood of his going away," she said.
"I think," he answered, "that there may be, and I wished to speak to
you about it."
He refrained from looking at her; he even delicately withdrew his
hand, so that if hers should lose its steadiness he might be
unconscious of it.
"Go away!" she exclaimed,—"from Washington? Laurence! Why
should you think so? I cannot imagine such a thing."
"He does not imagine it himself yet," he replied. "I am going to
suggest it to him."
Her hand was still upon his knee, and he felt her start.
"You are!" she said; "why and how? Do you think he will go? I do
not believe he will."
"I am not sure that he will," he answered, "but I hope so; and what
I mean is that I think it may be possible to send him abroad."
She withdrew her hand from his knee.
"He won't go," she said; "I am sure of it."
He went on to explain himself, still not looking at her.
"He is wasting his abilities," he said; "he is wasting his youth; the
position he is in is absurdly insignificant; it occurred to me that if I
used, with right effect, the little influence I possess, there might
finally be obtained for him some position abroad, which would be at
least something better, and might possibly open a way for him in the
future. I spoke to the Secretary of State about it, and he was very
kind, and appeared interested. It seems very possible, even
probable, that my hopes will be realized."
For a few seconds she sat still; then she said, abstractedly:
"It would be very strange to be obliged to live our lives without
Laurence; they would not be the same lives at all. Still, I suppose it
would be best for him; but it would be hard to live without Laurence.
I don't like to think of it."
In spite of his intention not to do so, he found himself turning to
look at her. There had been surprise in her voice, and now there was
sadness, but there was no agitation, no uncontrollable emotion.
"Can it be," he thought, "that she is getting over it? What does it
mean?"
She turned and met his eyes.
"But, whether it is for the best or not," she said, "I don't believe he
will go."
"My dear," he said, "you speak as if there was a reason."
"I think there is a reason," she answered, "and it is a strong one."
"What is it?" he asked.
"There is some one he is beginning to be fond of," she replied; "that
is the reason."
He kept his eyes fixed upon her.
"Some one he is beginning to be fond of?" he repeated.
"I don't know how it will end," she said. "I am sometimes afraid it
can only end sadly, but there is some one he would find it hard to
leave, I am sure."
The professor gradually rose in his chair until he was sitting upright.
"I wish," he said, "that you would tell me who it is."
"I do not think he would mind your knowing," she answered. "It
seems strange you have not seen. It is Agnes Sylvestre."
The professor sank back in his chair, and looked at the bed of coals
in the grate.
"Agnes Sylvestre!" he exclaimed; "Agnes Sylvestre!"
"Yes," she said; "and in one sense it is very hard on him that it
should be Agnes Sylvestre. After all these years, when he has
steadily kept himself free from all love affairs, and been so sure that
nothing could tempt him, it cannot be easy for him to know that he
loves some one who has everything he has not—all the things he
feels he never will have. He is very proud and very unrelenting in his
statement of his own circumstances, and he won't try to glaze them
over when he compares them with hers. He is too poor, she is too
rich—even if she loved him."
"Even!" said the professor. "Is it your opinion that she does not?"
"I do not know," she answered. "It has seemed to me more probable
that—that she liked Colonel Tredennis."
"I thought so," said the professor. "I must confess that I thought so;
though, perhaps, that may have been because my feeling for him is
so strong, and I have seen that he"—
"That he was fond of her?" Bertha put in as he paused to reflect.
"I thought so," he said again. "I thought I was sure of it. He sees
her often; he thinks of her frequently, it is plain; he speaks of her to
me; he sees every charm and grace in her. I have never heard him
speak of any other woman so."
"It would be a very suitable marriage," said Bertha; "I have felt that
from the first. There is no one more beautiful than Agnes—no one
sweeter—no one more fit"—
She pushed her seat back from the hearth and rose from it.
"The fire is too warm," she said. "I have been sitting before it too
long."
There was some ice-water upon a side table and she went to it and
poured out a glass, and drank it slowly. Then she took a seat by the
centre-table and spoke again, as she idly turned over the leaves of a
magazine without looking at it.
"When first Agnes came here," she said, "I thought of it. I remember
that when I presented Philip to her I watched to see if she
impressed him as she does most people."
"She did," said the professor. "I remember his speaking of it
afterward, and saying what a charm hers was, and that her beauty
must touch a man's best nature."
"That was very good," said Bertha, faintly smiling. "And it was very
like him. And since then," she added, "you say he has spoken of her
often in the same way and as he speaks of no one else?"
"Again and again," answered the professor. "The truth is, my dear, I
am fond of speaking of her myself, and have occasionally led him in
that direction. I have wished for him what you have wished."
"And we have both of us," she said, half sadly, "been unkind to poor
Laurence."
She closed the magazine.
"Perhaps he will go, after all," she said. "He may see that it is best.
He may be glad to go before the year is ended."
She left her book and her chair.
"I think I must go now," she said, "I am a little tired."
He thought that she looked so, and the shadow which for a moment
had half lifted itself fell again.
"No," he thought, "she has not outlived it, and this is more bitter for
her than the rest. It is only natural that it should be more bitter."
When he got up to bid her good-night she put a hand upon either of
his shoulders and kissed him.
"I am glad I was not invited to the grand party, dear," she said, "I
have liked this better. It has been far better for me."
There were only a few yards of space between her father's house
and her own, and in a few seconds she had ascended the steps and
entered the door. As she did so she heard Richard in the parlor,
speaking rapidly and vehemently, and, entering, found that he was
talking to Colonel Tredennis. The colonel was standing at one end of
the room, as if he had turned around with an abrupt movement;
Richard was lying full length upon a sofa, looking uneasy and
excited, his cushions tumbled about him. They ceased speaking the
moment they saw her, and there was an odd pause, noticing which
she came forward and spoke with an effort at appearing at ease.
"Do you know that this seems like contention?" she said. "Are you
quarrelling with Richard, Colonel Tredennis, or is he quarrelling with
you? And why are you not at the reception?"
"We are quarrelling with each other violently," said Richard, with a
half laugh. "You arrived barely in time to prevent our coming to
blows. And why are you not at the reception?"
Bertha turned to Tredennis, who for a moment seemed to have been
struck dumb by the sight of her. The memories the slender gray
figure had brought to the professor rushed back upon him with a
force that staggered him. It was as if the ghost of something dead
had suddenly appeared before him and he was compelled to hold
himself as if he did not see it. The little gray gown, the carelessly
knotted kerchief,—it seemed so terrible to see them and to be forced
to realize through them how changed she was. He had never seen
her look so ill and fragile as she did when she turned to him and
spoke in her quiet, unemotional voice.
"This is the result of political machination," she said. "He has
forgotten that we were not invited. Being absorbed in affairs of state
he no longer keeps an account of the doings of the giddy throng."
Then he recovered himself.
"You were not invited," he said. "Isn't there some mistake about
that? I thought"—
"Your impression naturally was that we were the foundation-stone of
all social occasions," she responded; "but this time they have
dispensed with us. We were not invited."
"Say that you did not receive your invitation," put in Richard,
restlessly. "The other way of stating it is nonsense."
She paused an instant, as if his manner suggested a new thought to
her.
"I wonder," she said, slowly, "if there could be a reason; but no, I
think that is impossible. It must have been an accident. But you,"
she added to Tredennis, "have not told me why you are not with the
rest of the world."
"I came away early," he answered. "I was there for an hour."
He was glad that she did not sit down; he wished that she would go
away; it would be better if she would go away and leave them to