http://www.developer.com/java/ent/article.php/10933_3577101_1
http://www.onjava.com/pub/a/onjava/2007/02/08/an-introduction-to-hibernate-3-annotations.html
more on
http://www.i-proving.ca/space/Technologies/Hibernate/Hibernate+Annotation+Examples/Collection+of+Elements
http://www.javakaffee.de/blog/2006/11/28/hibernate-annotation-for-a-map-of-some-enum-type-to-some-primitive-type/
Wednesday, December 12, 2007
Friday, December 7, 2007
Java Script Engine in JSDK6
Whats it?
The scripting API consists of interfaces and classes that define Java TM Scripting Engines and provides a framework for their use in Java applications. This API is intended for use by application programmers who wish to execute programs written in scripting languages in their Java applications. The scripting language programs are usually provided by the end-users of the applications.
The main areas of functionality of javax.script package include
Script execution: Scripts are streams of characters used as sources for programs executed by script engines. Script execution uses eval methods of ScriptEngine and methods of the Invocable interface.
Binding: This facility allows Java objects to be exposed to script programs as named variables. Bindings and ScriptContext classes are used for this purpose.
Compilation: This functionality allows the intermediate code generated by the front-end of a script engine to be stored and executed repeatedly. This benefits applications that execute the same script multiple times. These applications can gain efficiency since the engines' front-ends only need to execute once per script rather than once per script execution. Note that this functionality is optional and script engines may choose not to implement it. Callers need to check for availability of the Compilable interface using an instanceof check.
Invocation: This functionality allows the reuse of intermediate code generated by a script engine's front-end. Whereas Compilation allows entire scripts represented by intermediate code to be re-executed, Invocation functionality allows individual procedures/methods in the scripts to be re-executed. As in the case with compilation, not all script engines are required to provide this facility. Caller has to check for Invocable availability.
Script engine discovery and Metadata: Applications written to the Scripting API might have specific requirements on script engines. Some may require a specific scripting language and/or version while others may require a specific implementation engine and/or version. Script engines are packaged in a specified way so that engines can be discovered at runtime and queried for attributes. The Engine discovery mechanism is based on the Service discovery mechanism described in the Jar File Specification. Script engine implementing classes are packaged in jar files that include a text resource named META-INF/services/javax.script.ScriptEngineFactory. This resource must include a line for each ScriptEngineFactory that is packaged in the jar file. ScriptEngineManager includes getEngineFactories method to get all ScriptEngineFactory instances discovered using this mechanism. ScriptEngineFactory has methods to query attributes about script engine.
The scripting API consists of interfaces and classes that define Java TM Scripting Engines and provides a framework for their use in Java applications. This API is intended for use by application programmers who wish to execute programs written in scripting languages in their Java applications. The scripting language programs are usually provided by the end-users of the applications.
The main areas of functionality of javax.script package include
Script execution: Scripts are streams of characters used as sources for programs executed by script engines. Script execution uses eval methods of ScriptEngine and methods of the Invocable interface.
Binding: This facility allows Java objects to be exposed to script programs as named variables. Bindings and ScriptContext classes are used for this purpose.
Compilation: This functionality allows the intermediate code generated by the front-end of a script engine to be stored and executed repeatedly. This benefits applications that execute the same script multiple times. These applications can gain efficiency since the engines' front-ends only need to execute once per script rather than once per script execution. Note that this functionality is optional and script engines may choose not to implement it. Callers need to check for availability of the Compilable interface using an instanceof check.
Invocation: This functionality allows the reuse of intermediate code generated by a script engine's front-end. Whereas Compilation allows entire scripts represented by intermediate code to be re-executed, Invocation functionality allows individual procedures/methods in the scripts to be re-executed. As in the case with compilation, not all script engines are required to provide this facility. Caller has to check for Invocable availability.
Script engine discovery and Metadata: Applications written to the Scripting API might have specific requirements on script engines. Some may require a specific scripting language and/or version while others may require a specific implementation engine and/or version. Script engines are packaged in a specified way so that engines can be discovered at runtime and queried for attributes. The Engine discovery mechanism is based on the Service discovery mechanism described in the Jar File Specification. Script engine implementing classes are packaged in jar files that include a text resource named META-INF/services/javax.script.ScriptEngineFactory. This resource must include a line for each ScriptEngineFactory that is packaged in the jar file. ScriptEngineManager includes getEngineFactories method to get all ScriptEngineFactory instances discovered using this mechanism. ScriptEngineFactory has methods to query attributes about script engine.
Bit Shifting!
To shift a number one bit to the right, remove the rightmost bit and add a bit on the left. If the leftmost bit before the shift is 0, add a 0; if it is 1, add a 1.
So looking at your example 32 >> 3:
32 == 0010 0000
Shift this to the right three times, using the method described above. This gives:
0001 0000
0000 1000
0000 0100
So the answer is 0000 0100 == 4.
Note, you always have to take all the bits in the number into account. If your are shifting an int, which is 32 bits, you should look at all 32 bits:
0000 0000 0000 0000 0000 0000 0010 0000
So looking at your example 32 >> 3:
32 == 0010 0000
Shift this to the right three times, using the method described above. This gives:
0001 0000
0000 1000
0000 0100
So the answer is 0000 0100 == 4.
Note, you always have to take all the bits in the number into account. If your are shifting an int, which is 32 bits, you should look at all 32 bits:
0000 0000 0000 0000 0000 0000 0010 0000
Thursday, December 6, 2007
The "NULL" Type
There is also a special null type, the type of the expression null, which has no name. Because the null type has no name, it is impossible to declare a variable of the null type or to cast to the null type. The null reference is the only possible value of an expression of null type. The null reference can always be cast to any reference type. In practice, the programmer can ignore the null type and just pretend that null is merely a special literal that can be of any reference type.
class NameClass
{
static String name="xyz";
static NameClass getClass1()
{
System.out.println("inside method");
return null;
}
public static void main(String[] args)
{
System.out.println(getClass1().name);
}
}
the above code prints : inside method xyz
The variable name is declared as static. static variables and methods are not depends on the object instance
class NameClass
{
static String name="xyz";
static NameClass getClass1()
{
System.out.println("inside method");
return null;
}
public static void main(String[] args)
{
System.out.println(getClass1().name);
}
}
the above code prints : inside method xyz
The variable name is declared as static. static variables and methods are not depends on the object instance
Wednesday, December 5, 2007
Power of Velocity!
Velocity is known as just another open source product from ASF and used Template Engine. But Velocity is much more than that. It can be effectivly used as
1. Template Render
2. Code Generator
3. Rule Engine
etc
Lets have closer look at each of these capabilities
Contemporary technologies for web template engines are Freemarker, Groovy, Velocity, WebMacro and XSLT.
TODO: Comparative study of how these frameworkds work with Java
Also compare with Rules Engines such as Drools and Jess
1. Template Render
2. Code Generator
3. Rule Engine
etc
Lets have closer look at each of these capabilities
Contemporary technologies for web template engines are Freemarker, Groovy, Velocity, WebMacro and XSLT.
TODO: Comparative study of how these frameworkds work with Java
Also compare with Rules Engines such as Drools and Jess
Tuesday, December 4, 2007
THIS & SUPER in Static Context
You cannot call "super" from a static context. Just like you can't use "this" or call any non-static methods in a static context.
Subscribe to:
Posts (Atom)