Sunday, October 30, 2016

Inherit POJO configurations in Spring! - Reuse the common properties across classes!

How to reuse the pojo configurations of the same class hierarchy:(Homogeneous classes) 

How to solve the below example of rewriting the same properties in all the beans !!

<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="sequenceGenerator" class="com.apress.springrecipes.sequence.SequenceGenerator"> <property name="initial" value="100000" /> <property name="suffix" value="A" /> <property name="prefixGenerator" ref="datePrefixGenerator" /> </bean> <bean id="sequenceGenerator1" class="com.apress.springrecipes.sequence.SequenceGenerator"> <property name="initial" value="100000" /> <property name="suffix" value="A" /> <property name="prefixGenerator" ref="datePrefixGenerator" /> </bean> <bean id="datePrefixGenerator" class="com.apress.springrecipes.sequence.DatePrefixGenerator"> <property name="pattern" value="yyyyMMdd" /> </bean> </beans>

Solution:
<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="baseSequenceGenerator" class="com.apress.springrecipes.sequence.SequenceGenerator"> <property name="initial" value="100000" /> <property name="suffix" value="A" /> <property name="prefixGenerator" ref="prefixGenerator" /> </bean> <bean id="sequenceGenerator" parent="baseSequenceGenerator" /> <bean id="sequenceGenerator1" parent="baseSequenceGenerator" /> </beans>

Or


How to reuse the pojo configurations of the different class hierarchy: (Heterogeneous classes)  i.e Inherit Properties from Parent POJOs with Different Classes:

For example, let's add another ReverseGenerator class that also has an initial property.
package com.apress.springrecipes.sequence;

public class ReverseGenerator 
{
    private int initial;
    public void setInitial(int initial) 
    {
           this.initial = initial;
    }
}

Now SequenceGenerator and ReverseGenerator don't extend the same base class—that is, they're not in the
same class hierarchy, but they have a property of the same name: initial. To extract this common initial property,
you need a baseGenerator parent bean with no class attribute.

<?xml version="1.0" encoding="UTF-8"?> <beans> <bean id="baseGenerator" abstract="true"> <property name="initial" value="100000" /> </bean> <bean id="baseSequenceGenerator" abstract="true" parent="baseGenerator" class="com.apress.springrecipes.sequence.SequenceGenerator"> <property name="suffix" value="A" /> <property name="prefixGenerator" ref="prefixGenerator" /> </bean> <bean id="reverseGenerator" parent="baseGenerator" class="com.apress.springrecipes.sequence.ReverseGenerator" /> <bean id="sequenceGenerator" parent="baseSequenceGenerator" /> <bean id="sequenceGenerator1" parent="baseSequenceGenerator" /> <bean id="sequenceGenerator2" parent="baseSequenceGenerator" /> </beans> 



Friday, October 21, 2016

How to use the most useful software that you have!

These are the options that it supports to customize it:

1, add -p parameter that specifies the listening port
2, add the -u parameter is used to specify a user name
3, add -prolongationPeriod parameters. 

Hope you got it!

Friday, October 14, 2016

Listing files that were changed in a certain range of time

Here is the simple thing, that you can do to crack the list!

touch -t 201610110000 startTime 
touch -t 201611110000 stopTime 
find . -newer startTime \! -newer stopTime

Monday, October 3, 2016

Port forwarding in linux!

Remote Machine: ssh -Lserver-port:localhost:destination-port destination-user@destination-ip

eg:
ssh -L6190:localhost:389 admin@ldap1

Local Machine: ssh -Llocalhost-port:localhost:server-port server-user@server-ip

eg:
ssh -L6190:localhost:6190 admin@web

Cheers,

RK 

please consider the environment before printing