Wednesday, April 24, 2013

Vocabulary (http://www.se-radio.net/)

bugle: curious George, daily bugle on Spider Man
Mahout: apache mahout
Agile (pronunciation)

Episode 188: Requirements in Agile Projects

Java web service


JAX-WS
Big web services use XML messages that follow the Simple Object Access Protocol (SOAP) standard, an XML language defining a message architecture and message formats.
A SOAP-based design must include the following elements.
A formal contract must be established to describe the interface that the web service offers. WSDL can be used to describe the details of the contract, which may include messages, operations, bindings, and the location of the web service. You may also process SOAP messages in a JAX-WS service without publishing a WSDL.
The architecture must address complex nonfunctional requirements. Many web service specifications address such requirements and establish a common vocabulary for them. Examples include transactions, security, addressing, trust, coordination, and so on.
The architecture needs to handle asynchronous processing and invocation. In such cases, the infrastructure provided by standards, such as Web Services Reliable Messaging (WSRM), and APIs, such as JAX-WS, with their client-side asynchronous invocation support, can be leveraged out of the box.

In JAX-WS, a web service operation invocation is represented by an XML-based protocol, such as SOAP. The SOAP specification defines the envelope structure, encoding rules, and conventions for representing web service invocations and responses. These calls and responses are transmitted as SOAP messages (XML files) over HTTP.
Although SOAP messages are complex, the JAX-WS API hides this complexity from the application developer. On the server side, the developer specifies the web service operations by defining methods in an interface written in the Java programming language. The developer also codes one or more classes that implement those methods. Client programs are also easy to code. A client creates a proxy (a local object representing the service) and then simply invokes methods on the proxy. With JAX-WS, the developer does not generate or parse SOAP messages. It is the JAX-WS runtime system that converts the API calls and responses to and from SOAP messages.

Sunday, April 21, 2013

Cherry blossoms 2013 at high park


Cherry blossoms 2013

The buds are swelling and will almost certainly start opening on the weekend of the 27th, however, full blooming may not happen until a few days later.

Monday, April 15, 2013

The best way to use eclipse galileo with SVN and maven support


1. The smallest eclipse version size is Java developer version (less than 100M)
eclipse-java-galileo-win32.zip
2. Install SVN plugin manually by copying the features and plugins files
Attached.
3. Do not install maven plugin since it will make eclipse slower and unresponding sometimes.
Create a simple .bat file, the only content could be only "mvn package", and configure it into Run -> External Tools

Enjoy the smallest and fasted eclipse with SVN and maven support

Friday, April 12, 2013

use SLF4J with Logback


It's recommend to use SLF4J with Logback.

1. Better performance
2. Better integration to SLF4J (marker for example)
3. By default using BasicConfigurator so that there's no pain to begin
4. logback-test.xml is easier to test
logback.groovy -> logback-test.xml -> logback.xml -> BasicConfigurator
5. Easier to track (below or <configuration debug="true">)
LoggerContext lc = (LoggerContext) LoggerFactory.getILoggerFactory();
    // print logback's internal status
    StatusPrinter.print(lc);
6. You may specify the location of the default configuration file with a system property named "logback.configurationFile"

import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.slf4j.Marker; import org.slf4j.MarkerFactory; public class HelloLogback { private static final Logger logger = LoggerFactory.getLogger(HelloLogback.class); static Marker SMTP_TRIGGER = MarkerFactory.getMarker("SMTP_TRIGGER"); public static void main(String[] args) { logger.info("test 2"); logger.error("just another test 2"); logger.info(SMTP_TRIGGER,"ended"); } }



<configuration debug="true">
  <statusListener class="ch.qos.logback.core.status.OnConsoleStatusListener" />
  <appender name="FILE" class="ch.qos.logback.core.FileAppender">
    <file>myApp.log</file>
<append>true</append>
    <encoder>
      <pattern>%date %level [%thread] %logger{10} [%file:%line] %msg%n</pattern>
    </encoder>
  </appender>
  
  <appender name="EMAIL" class="ch.qos.logback.classic.net.SMTPAppender">
    <smtpHost>smtp.gmail.com</smtpHost>
    <smtpPort>465</smtpPort>
    <SSL>true</SSL>
    <username>xxxxxxxxx@gmail.com</username>
    <password>xxxxxxxx</password>

    <to>xxxxxxxxxxx@gmail.com</to>
    <from>xxxxxxxxxxxxxxxxxx@gmail.com</from>
    <subject>TESTING: %logger{20} - %m</subject>
    <layout class="ch.qos.logback.classic.PatternLayout">
      <pattern>%date %-5level %logger{35} - %message%n</pattern>
    </layout>       
    <cyclicBufferTracker class="ch.qos.logback.core.spi.CyclicBufferTrackerImpl">
      <!-- send just one log entry per email -->
      <bufferSize>10</bufferSize>
    </cyclicBufferTracker>
  </appender>

  <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
    <!-- encoders are assigned the type
         ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
    <encoder>
      <pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</pattern>
    </encoder>
  </appender>

  <root level="debug">
    <appender-ref ref="FILE" />
    <appender-ref ref="EMAIL" />
    <appender-ref ref="STDOUT" />
  </root>
  
</configuration>

Monday, April 8, 2013

expert one on one Oracle_note


1.
To get a repeatable read in Oracle, set the isolation level to serializable instead of using select for update
which you only do when you want  to physically serialize access to data.

2.
If all the statements execute very rapidly, then MTS works well. Or other user will hang
select * from v$session where  type = 'USER' and username='ACNDEV'

3.
Oracle locks data at the row level on modification only. There's is no lock escalation to a block or table level
Oracle never locks data just to read it. There are no locks placed on rows of data by simple reads.
A writer of data does not block a reader of data. (different from almost every other database, where reads are blocked by writes)
A writer of data is blocked only when another writer of data has already locked the row it was going after.

4.
In Oracle, Null is neither equal to nore not equal to Null. In Sybase and SQL Serverr, Null equals null.

5.
While a stored procedure is executing, the procedure itself is locked in a mode that allows others to execute it, but will not permit another user to alter it in any way.

6.
If the parent table row is deleted (before commit), then the entire table will be locked (in the absence of an index)

7.
Select ... for update places the row exclusive lock and ROW SHARE TABLE lock (to prevent table structure modification by other user)

8.
B*Tree index is used mostly (one key to one row/range) while Bitmap index is used for low cardinality data (Y,N and null).