you can download all the extensions related to jdeveloper from this location
http://www.oracle.com/technetwork/developer-tools/jdev/index-099997.html
you can download all the extensions related to jdeveloper from this location
http://www.oracle.com/technetwork/developer-tools/jdev/index-099997.html
Hurray….
I am now an Oracle certified Application Development Framework Implementation specialist.
I wrote the 1Z0554 exam yesterday.. and managed to passed the exam..
My certification status currently is
First blog of mine 4m my blackberry curve
Add the following jstl function library to the jsp:root tag
xmlns:fn=http://java.sun.com/jsp/jstl/functions
and proceed with
text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.next ,'@')}"
text="goto page# #{fn:substringAfter(controllerContext.currentViewPort.taskFlowContext.trainModel.previous ,'@')}"
some of the values that you can get related to trainModel previous and next actions are
#{controllerContext.currentViewPort.taskFlowContext.trainModel.goNext}
#{controllerContext.currentViewPort.taskFlowContext.trainModel.goPrevious}
Note: to get the display name from the trainstop you have to manually have the binding for next and previous strings added to the bean and evaluate the text manually like
public class Bean {
TrainModel train;
TrainStopModel trainStopModel;
String next;
String previous;
public Bean() {
PageFlowStack stack = StateUtils.getCurrentViewPort().getPageFlowStack();
if (stack.size() > 0)
{
train = stack.peek().getTrainModel();
}
}
public static Object evaluateEL(String el) {
FacesContext facesContext = FacesContext.getCurrentInstance();
ELContext elContext = facesContext.getELContext();
ExpressionFactory expressionFactory =
facesContext.getApplication().getExpressionFactory();
ValueExpression exp =
expressionFactory.createValueExpression(elContext, el,
Object.class);
return exp.getValue(elContext);
}
public void setNext(String next) {
this.next = next;
}
public String getNext() {
trainStopModel = train.getNextTrainStop(train.getCurrentTrainStop());
this.next = trainStopModel.getTextAndAccessKey();
return next;
}
public void setPrevious(String previous) {
this.previous = previous;
}
public String getPrevious() {
if(train != null){
trainStopModel = train.getPreviousTrainStop(train.getCurrentTrainStop());
this.previous = trainStopModel.getActivityId().getLocalActivityId();
}
return previous;
}
}
Recently i wanted to install php and apache on Oracle Enterprise linus which was upgraded to linux64.
When I tried the solution given in
http://wiki.apache.org/tomcat/UsingPhp
http://dan.drydog.com/apache2php.html
I keep getting the following error when I
make or make install
the error is like
#> gcc gcc.orig: unrecognized option '-static-libgcc-B/usr/lib/gcc/i386-redhat-linux6E/4.4.0' gcc.orig: no input files
This clearly proves that there is a problem in the linux64
I tried all possible tricks on earth but could get away with it.
Finally i tried the following and it worked..
#> which gcc #> /usr/bin/gcc #> ls /usr/bin/gcc* #> gcc gcc34 gcc41 gccmakedep gcc44 gcc.orig #> mv /usr/bin/gcc /usr/bin/gcc_old #> mv /usr/bin/gcc34 /usr/bin/gcc #> gcc: no input files
Why map is not a collection?
collection acts upon values. map acts on key value pair
Why the finalize method is protected?
Finalize method is for the JVM to execute before GC.imagine if finalize is public then any object can call directly which is not what we wanted. If you have some open connection you can write cleanup codes in the finalize method in your class and leave the rest of the work to the JVM to call the finalize method.
The finalize method is made protected for the subclass to override it or any finalize operations.
Can a finalize method be called for twice?
The finalize method is never invoked more than once by a Java virtual machine for any given object.
Any exception thrown by the <code>finalize</code> method causes the finalization of this object to be halted, but is otherwise ignored.
why the clone is protected?
clone is protected because it is something that ought to be overridden so that it is specific to the current class.It’s protected so you don’t use the one in object (it’ll just throw an exception anyway). They want you to override it in a class, then you make it public
How to convert BigDecimal to Integer?
BigDecimal b = new BigDecimal("123");
Integer i = new Integer(String.valueOf(b));
Why Serializable and Cloneable is not having anything?
Serializable and Cloneable are called marker or tag interface because they tag all derived class on purpose. Java has a default clone() method in Object class which should not be applied for all the class. So whenever user creates a class the object is not cloneable. The object is cloneable only when it has the marking of Cloneable interface. if any class implements Cloneable then it is understood by the JVM that the object is eligible for cloning and Object by default provides the cloning method this also provide the class to implement their own clone operation by making it protected
The class is marked Serializable for the JVM to understand that the class can be serialized
Singleton pattern in java can be implemented by the approaches explained here
Now here is the code to break it using reflection
public class NormalClass{
private NormalClass(){ //having private constructor
}
private void print(){
System.out.println(&quot;broken&quot;);
}
}
/////////////////////////////////
public class Main{
public static void main(String[] args) throws InstantiationException, IllegalAccessException, SecurityException, NoSuchMethodException, IllegalArgumentException, InvocationTargetException {
Class c = NormalClass.class;
final Constructor con = c.getDeclaredConstructor();
System.out.println(con);
final Method meth = c.getDeclaredMethod(&quot;print&quot;, null);
//---- You will get IllegalAccessException without this ---
AccessController.doPrivileged(new PrivilegedAction() {
public Object run() {
con.setAccessible(true);// turning off the access check
meth.setAccessible(true);// turning off the access check
return null;
}
});
NormalClass n = (NormalClass)con.newInstance(null);
meth.invoke(n,null);
}
}
Why do we use Annotations?
Annotations give information about the java program and is not part of the program itslf
They give inforamtion to the compiler for Compiler time processing, deployment time processing and runtime processing
Some of the annotations are
@Author(
name="vinod",
date="3/12/2010"
)
public class MyClass{}
@suppressWarnings{value="unchecked"}
public void myMethod(){}
@override
public void run(){}
@Deprecated
public void printWriter(){}
There are two types of annotations
Simple and Meta Annotations
Simple Annotations – provided by JDK5
* Override
* Deprecated
* Suppresswarnings
Meta Annotations – Annotations of Annotation
* Target
* Retention
* Documented
* Inherited
Target – target element for which the annotation is applicable
* @Target(ElementType.TYPE) – applied to any element of a class
* @Target(ElementType.FIELD) – applied to a field or property
* @Target(ElementType.METHOD) – applied to a method level annotation
* @Target(ElementType.PARAMETER) – applied to the parameters of a method
* @Target(ElementType.CONSTRUCTOR) – applied to constructors
* @Target(ElementType.LOCAL_VARIABLE) – applied to local variables
* @Target(ElementType.ANNOTATION_TYPE) – indicates that the declared type itself is an annotation type
Retention – how long the annotations should be retained
* RetentionPolicy.SOURCE – retained only at the source level and will be ignored by the compiler
* RetentionPolicy.CLASS – retained by the compiler at compile time, but will be ignored by the VM
* RetentionPolicy.RUNTIME – retained by the VM so they can be read only at run-time
Documented – should be documented in by the javadoc tool
Inherited -annotations of the parent class is inherited to the subclass
Self explanatory Producer and Consumer problem
Producer.java
package com.producer;
import java.util.ArrayList;
import java.util.Random;
public class Producer implements Runnable{
//Engine Batch ID reference
ArrayList engineList;
//Engine No is stored here
String str;
//Assigning the BATCH ID reference
public Producer(ArrayList engineList) {
this.engineList = engineList;
}
/*
* Produce Engines
*/
public void produce(){
//Random number for engine number
str = ""+Math.abs(new Random(System.currentTimeMillis()).nextLong());
//Only one thread can enter the BATCH for any operation
synchronized (engineList) {
//Add the Engine to the batch
engineList.add(str);
//Notify all other threads that the new engine is added to the BATCH
engineList.notifyAll();
}
//Print Engine Number
System.out.println("Produced :: ENGINE CHASIS NO ["+ str + "]");
}
@Override
public void run() {
System.out.println("Production started");
//10 Engine is to be produced
for(int i=0;i<10;i++){
try {
//Produce the engine
this.produce();
//Sleep for 2 seconds for the next operation
Thread.sleep(2000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Consumer.java
package com.producer;
import java.util.ArrayList;
public class Consumer extends Thread{
//Engine Batch ID reference
ArrayList<String> engineList;
//Engine No is stored here
String str;
//Assigning the BATCH ID reference
public Consumer(ArrayList<String> engineList) {
this.engineList = engineList;
}
/*
* Consume Engines from the BATCH
*/
public void consume(int index) throws InterruptedException{
//Only one thread can enter the BATCH for any operation
synchronized (engineList) {
//if the Batch has no engines
while(engineList.size() == 0){
//then wait for some time until you get a new engine to consume
engineList.wait();
}
//If the engine is deployed to the BATCH
if(engineList.size() >= 0){
//The consume the engine from the respective position
str = engineList.get(index);
}
}
//Print Engine Number that it has been consumed
System.out.println("Consumed :: -------> ENGINE CHASIS NO ["+ str + "]" );
}
@Override
public void run() {
//10 Engine has to be consumed
for(int i=0;i<10;i++){
try {
//Produce the engine
this.consume(i);
//Sleep for 3 seconds for the next operation
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
}
Main.java
package com.producer;
import java.util.ArrayList;
public class Main {
public static void main(String[] args) throws InterruptedException {
//ArrayList to store the produced engines - BATCH
ArrayList<String> engine = new ArrayList<String>();
//Producer taking the engine BATCH ID Reference
Producer producer = new Producer(engine);
//Consumer taking the reference of the engine BATCH ID Reference
Consumer consumer = new Consumer(engine);
//Threads
Thread prodThread = new Thread(producer);
Thread conThread = new Thread(consumer);
//Starting the production
prodThread.start();
//Start Consumption
conThread.start();
}
}