Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!

luri ron

Ranch Hand
+ Follow
since Dec 11, 2008
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by luri ron

in log4j implementation, the log4j xml parser can recognize a java system property in the xml file such as ${LOGDIR}

i m trying to do the same thing using plain jdk dom parser, but i couldn't make it work. what do i need to do to have DocumentBuilder to recognize a java system property in the xml file.

code snippet. but it throws exception

try {
System.setProperty("ROOTCONFIG", "../app/proj");
DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder dBuilder = dbFactory.newDocumentBuilder();
String s = "<?xml version=\"1.0\" encoding=\"UTF-8\"?> <!DOCTYPE document [ <!ENTITY mytest SYSTEM '${ROOTCONFIG}/config/externalenv/nonprod/test.xml'>]> <test>&mytest;</test>";
Document doc = dBuilder.parse(new ByteArrayInputStream(s.getBytes()));
catch ( Exception e ) {
e.printStackTrace();
}

here is the exception as ROOTCONFIG is not expanded.

java.net.MalformedURLException: no protocol: ${ROOTCONFIG}/config/externalenv/nonprod/test.xml
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at java.net.URL.<init>(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLEntityManager.startEntity(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanEntityReference(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl$FragmentContentDriver.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentScannerImpl.next(Unknown Source)
at com.sun.org.apache.xerces.internal.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XML11Configuration.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.XMLParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.baml.oms.util.DomTest.testDom(DomTest.java:19)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Any rup expert can comment on this?
in my previous experience, we don't provide a documentation. when you demo, you show the user a working software which itself is much better than a document. however, one document to describe the features that are demoed, and the non-functional features should be handy for the discussion. in term of formalities of the document, it should ahere to a consistent format.
In RUP, which role lead the development team in a day to day activities and they perform a lot of tasks associated with the project manager such as technical tast estimation and communicate status and issues to the pm?
you mean maven.

these are more build tools with a deploy plugin. there is no change control in place, and no audit trails either.
10 years ago
can someone suggest one? it is not just ftp or xcopy, i am looking for some tools that will does change control and audit trail for the java software deployment.
10 years ago
In my past experience, sharepoint is used to share documentation.
if a multi-thread program is run on single processor system, is volatile keyword required?
i am under the impression that volatile is required in a multi-processor sytem to ensure that the cpu access the variable using the main memory but not from the local cpu cache.
10 years ago
having self orgnize team is not just about trust, and it also depend on the skill set and experience of the developers in the team. instead of fully adopt scrum or extreme programing or rup, my experience is to take some of the concept and apply them to your project in orgnization.

for example, from scrum, collobration of key people cross function early on and a demo at end of each iteration are very useful.
from extreme programing, the continue building and intergration and automation of functional test, and team ownership of code base are very useful. from rup, the concept visual modelling and design, risk analysis, tackle of high risk and high value item at the early phase of the release, and the 4 concrete phases (inception, elaboration, construction, and transition) are very useful.

one of the most critical point to build software fast, cheap, and good is to have a lot of automated unit test, intergrated test, and system test. this doesn't mean that you will take out the qa process. it will help provide a decent baseline for your development release.
make sense. what is the need to have an array based implementation of queue?

You can use observer pattern for that. Suppose CacheManager class loads/refreshes data, register that as observer with DataUpdater class to update sequentially. This will be asynchronous approach and is the suggested one in case it takes more than a couple of seconds to refresh data.



just want to point out one thing. observer/observee doesn't get you asynchronous. it is how you how implement the notify of the observer. asynchronous means that the thread submit a request without waiting for the request to be processed completly. as long as the request is accepted, the thread moves on to process next. if you are interested in result of request being processed, you will need to have another thread to process the results.
11 years ago

1) Whats the difference between synchronized block and method level synchronization?


synchronized block is to acquire the monitor for the object/class you synchronized on.
syncrhonized method is to acquire the monitor of "this"

2)why method level synchronization is not preferred? how does it slows down the performance?


for performance purpose, you would only want to synchronized on the code block need to be synchronized. not the whole method.

3)I dont know if this question is related to threads, i thought it might be achieved through threads,

If two persons at the same time are trying to buy ticket for the same seat in a Airplane? How to avoid this situation and not let the seat become blocked?

can this be achieved using Threads?


synchronized would work in this case. as jdk 1.5/1.6, you could use CompareAndSet which is use less instructions but achieve the same effect as synchornized.


Classic case is having a lock on a queue, with two different condition vars -- one for when the queue is empty, waiting for data, and one for when the queue is full, waiting for room.



for performance purpose, you would have 2 different locks, one for head and one for tail. and each one has its own condition.
obtaining instrinsic lock means the thread has acquired the monitor of the object. no thread can acquire the same montior until it is released.
if you use wait/notify, here is the code snipet

what it does is first acquire the monitor, put itself on wait for the notification, then release the monitor. And once it is notified, the thread will aquire the monitor first before it can execute methodA and methodB. and after the whole is executed and exited, the monitor is released.

for await use case;


ReentrantLock lock;
Condition notEmpty = lock.newCondition();
Condition otherCondition = lock.newCondition ();

...
lock.lock ()
try
{
notEmpty.await ();
..
}
finally
{
lock.unlock ();
}


similar sequence as wait, but you can have different conditions created for the same lock.

to notify a wait, you use notify.
to notify a condition.await, you use condition.signal.
also, most of the time, people use a spin lock during the wait to avoid race condition
hope this help.....
Matt, if you use java Double,Integer to get the number value,
you will creat at least temp objects such as string and floatingdecimal. If you are parsing
million of these, the performance won't be good.
11 years ago