Showing posts with label type. Show all posts
Showing posts with label type. Show all posts

Friday, December 15, 2017

Bean Loading Type In Spring

Bean Loading Type In Spring


Loading the bean which is configured in the Spring-context.xml file, can be done in two ways :

1. Eager loading or Aggressive loading
2. Lazy Loading
    Eager loading or Aggressive loading 
    In the case of Aggressive loading all the beans will be loaded and initialized at container start-up. It is called as eager or aggressive loading because of loading all the bean , instance instantiated and initializing at the container start-up only. We just have to write some configuration in the XML file to indicate container for eager loading. This loading is at the bean level . 

    To load any bean aggressively we have to mention lazy-init="false" . 
    Note that this configuration is at the bean level that means if we want to load all the configured bean to load eagerly then have to mention in each bean tag. If not mention then also by default it load eagerly.  

    Lazy loading 
    In the case of lazy loading all the beans will be loaded, instantiated and initialized when the container try to use them by calling getBeans() method. We just have to mention lazy-init="true" in order to load the beans lazily. 
    So bean will be loaded according to the configured lazy-init attribute with its corresponding value , or if not mentioned then by default it load Eagerly.  

    Note : All bean having singleton scope will follow aggressive loading and all bean with prototype scope will follow lazy loading.

    To know more about bean scopes - Click Here

    Available link for download

    Read more »

    Friday, May 5, 2017

    Bash variables type

    Bash variables type


    Unlike many other programming languages, Bash does not separate its variables by "type". Essentially, Bash variables are character strings, but, depending on context, Bash permits integer operations and comparisons on variables. The determining factor is whether the value of a variable contains only digits.
    Integer or string?
    a=2334
    # Integer.
    let "a += 1"
    echo "a = $a "
    # a = 2335
    # Integer, still.

    b=${a/23/BB}
    # Substitute "BB" for "23".
    # This transforms $b into a string
    .
    echo "b = $b"
    # b = BB35
    declare -i b
    # Declaring it an integer doesnt help.
    echo "b = $b"
    # b = BB35

    let "b += 1"
    # BB35 + 1 =
    echo "b = $b"
    # b = 1
    c=BB34
    echo "c = $c"
    # c = BB34
    d=${c/BB/23}
    # Substitute "23" for "BB".
    # This makes $d an integer
    .
    echo "d = $d"
    # d = 2334
    let "d += 1"
    # 2334 + 1 =
    echo "d = $d"
    # d = 2335
    # What about null variables?
    e=""
    echo "e = $e"
    # e =
    let "e += 1"
    # Arithmetic operations allowed on a null variable?
    echo "e = $e"
    # e = 1
    # Null variable transformed into an integer.

    # What about undeclared variables?
    echo "f = $f"
    # f =
    let "f += 1"
    # Arithmetic operations allowed?
    echo "f = $f"
    # f = 1
    # Undeclared variable transformed into an integer.

    The burden is on the programmer to keep track of what type the script variables are.
    Bash will not do it for you.
    But “declare” or “typeset “built-ins permit restring the properties of variables.
    This is very weak form of the typing available in certain programming languages
    .

    Ex:1
    declare –i number
    # The script will treat subsequent occurrences of “number” as an integer
    number=3
    echo “Number = $number”
    # Number = 3
    number=three
    echo “Number = $number”
    #Number = 0
    #Tries to evaluate the string “three” as an integer

    Available link for download

    Read more »