All 15 entries tagged Spring-Hibernate-Jboss

No other Warwick Blogs use the tag Spring-Hibernate-Jboss on entries | View entries tagged Spring-Hibernate-Jboss at Technorati | There are no images tagged Spring-Hibernate-Jboss on this blog

June 08, 2007

302 Redirect

HttpServletResponse.sendRedirect and Spring’s RedirectView both send a 302 back to client and expect client to immediately retry the value specified in the “location” field in the header


A URL for this view is supposed to be a HTTP redirect URL, i.e. suitable for HttpServletResponse’s sendRedirect method, which is what actually does the redirect if the HTTP 1.0 flag is on, or via sending back an HTTP 303 code – if the HTTP 1.0 compatibility flag is off.

November 07, 2006

Singleton in Spring

Follow-up to Singleton in Spring from Oracle/Java/Others

A spring bean default to be singleton. The following class is a Spring bean

Class Transform{
   private Map errors = new HashMap();
   public void setErrors(final Map errors) {
        this.errors = errors;
  }
  public void transform(){
   if(errors.isEmpty()){
    // do something
  } 
}

}

One thread call setErrors() and call transform() to finish it job. The next thread has to remember to call the setErrors() before call transform(), otherwise it will get the values of previous thread.

might safter to change the method signature to

Class Transform{
  public void transform(Errors errors){
   if(errors.isEmpty()){
    // do something
  } 
}
}

So you do not need to call the setErrors(), which is forgettable.


October 11, 2006

Starting sequence of Spring Web App

The sequence is :
Listener, filter, frameWorkServlet

Details:

Standard container startup
configuring application event listeners
sending application start event
contextLoaderListener -> contextLoader -> WebApplicationContext

Starting filters
start FrameworkServlet
Load webApplicationContextfor FrameworkServlet
Pre-instantiating singletons in factory


July 03, 2006

Spring Check box

How the propertyEditor works?
BeanWrapperImpl.class

When binding value from submissions:

PropertyEditor pe = findCustomEditor(requiredType, fullPropertyName);
pe.setValue(oldValue);
pe.setAsText((String) convertedValue);
convertedValue = pe.getValue();

When binding value to show form:

 PropertyEditor customEditor = getCustomEditor(fixedField);
 customEditor.setValue(value);
 String textValue = customEditor.getAsText();

Now the PropertyEditorSupport.setValue(values) will set the value of its variable holding the object to be converted.

How Spring bind the index/array element to parameters?

BeanWrapperImpl know how to bind array/list/set/map to a index peroperty
BeanWrapperImpl.getPropertyType ()
1. First check an indexed/ampped property
can deal with the following parameters in indexed format:
array, List, Set, Map
throw:
Property referenced in indexed property path ’” + propertyName +
”’ is neither an array nor a List nor a Set nor a Map; returned value was [” + value + “]”);

2. Check to see if there is a custom editor,

will call:
BindStattus:
getCustomEditor(this.expression)
this.value = this.errors.getFieldValue(this.expression);

how Spring bind the parametes to array/list?

ServletRequestDataBinder binder = bindAndValidate(request, command);
BaseCommandController.initBinder will give user chance to register CustomEditors
and will call onInitBinder, i.e, to reset the checkbox element vlaue:
_onInitBinder:((Command classs) binder.getTarget).setProperty(false)_

binder.bind -> DataBinder.doBind _ BeanWrapperImpl.setPropertyValue will know how to bind a parametes name2 to an array or list. the index [2] is ripped.


June 20, 2006

Singleton in Spring

Today I found an error in my project related to the singleton in Spring.

A class Pager is a Spring bean injected to a controller by IoC container.
In one method of the controller, it use Pager.data variable to store submissions from a form.

If two threads send the request at the same time, then Pager.data was written twice. So potentially the controller will return wrong result for one form.


April 27, 2006

Hibernate 3

Title:
Rating:
3 out of 5 stars
  • P151: Open Session view is not the first choice. Should fecht the completed required graph in the first place, using HQL or criteria queries, with a sensible and optimized defualt fetching strategy in the maping metadata for all other cases
  • P110: Line10 How to interpret that?

Thus if we noly call items.getBids().add(bid), no changes will be made persistent

With cascade=”all”, hibernte will persist the bid instance. However, the value of the foreign key column is not set


April 26, 2006

Inverse attribute of Hibernate

Writing about Hibernates bizarre interpretation of inverse ;) from Colin's blog

Think inverse as the “ignore”
inverse = true means to ignore the relationship of this side
inverse = false means not to ignore the relationship of this side

In parent-child relationship, parent is one side and children are many side.

one-to-many inverse=”false”
means relationship of parent side should not be ignored. So
parent.getChildren() will be examined, child.getParent() is ignored

For the following example:
Parent parentA = getParentA();
Parent parentB = getParentB();
child = new Child();
parentA.getChildren().add(child); Will be used
child.setParent(parentB); Will be ignored


January 13, 2006

Spring AOP

Follow-up to Spring Training from Oracle/Java/Others

Concept

Aspect and Advisor are interchangeable
Pointcut is refinement of join point

Aspect, Join point, Poincut advice are generic and appl to .net as well.
Advisor is specific to Spring

Proxy:

it is just a wrapped target.
It need to associate with Advice/Interceptor and let Advice/Interceptor to let the job

Dynamic proxy:
Every method(defined in the interface) invocation wil go through proxy first

invocation.proceed() = chain.doFilter()

1.explicit creation of AOP proxies:

using a ProxyFactoryBean or similar factory bean

ProxyFactoryBean has properties: P24

1) proxyInterfaces: the interface to proxy

2) target: the target object to be proxyed, which should implemnts interface

3) interceptorNames: the name of advice;they are ORDERED!

2. use "autoproxy" bean definitions

can automatically proxy selected bean definitions:

Two ways to do this:

1) Using an autoproxy creator that refers to specific beans in the current context

BeanNameAutoProxyCreator: beanNames && interceptorNames (be aware of maintenance cost)

DefaultAdvisorAutoproxyCreator:

2) Autoproxy creation driven by source-level metadata attributes

(This is a special case of autoproxy creation that deserves to be considered separately)

Types
Around advice: MethodInterceptor
Before advice: MethodBeforeAdvice
After advice: AfterReturningAdvice

Pointcut

Pointcut will select some method to apply advice

JdkregexpmethodPointcut

TransactionAtributeSroucePointcut

PointCut and Advice: P57

General: DefaultPointcutAdvisor has properties: pointcut & advice
NameMatchMethodPointcutAdvisor has properties: mappedNames(do not need to configure pointcut separately) & advice

Dynamic pointcuts incures significant performance penalty

Others:

Monosodium glutamate
c# c sha


January 11, 2006

Spring Training

Note how the TransactionProxyFactoryBean above is named gameRenter. This is because it will produce a transactional GameRenter implementation and that is what we want to expose to client code (not the raw business object.)

It is using FactoryBean.
The tutor emphasized that FactoryBean will return its producer.

AbstractTransactionalDataSourceSpringContextTests
It is very useful for unit test. It will help to re-instate the status of test database

Transaction
To implements declarative transaction, you can use AOP or AspectJ or something else.

For AOP, the logic flow is as follows:

Advisor -> Interceptor ->TransactionManager & transactionAttributeSource
TransactionAttributeSource -> MatchAlwaysTranstionAttributeSource | metadata.commons.CommonsAttributes


April 07, 2005

ReConfig oracle DS in JBOSS

This morning I tried to re-config oracle without restart jboss.
In JMX console, I tried: stop/destroy and means and then start/create mbean.
It just refused to pick up the new changes, complaining:
XML document structures must start and end within the same entity…


Search this blog

Search Warwick Blogs

 

Tags

Most recent comments

  • Oracle 11g is the clear leader in this area. Oracle has invested heavily into self–tuning capabiliti… by shaane on this entry
  • All the features are very nice.I like Repair Advisors the most.Oracle 10G introduced some of the dat… by lucy on this entry
  • "logical standby failed to re–start, I am also getting the same error. I have search on internet and… by anemia on this entry
  • Thanks for the nice information because from last three days i am stuck on this problem…. by robot vacuum on this entry
  • So what happen City speed dating when you tried this coding once in your PC.. Please tell me so i am… by John Bergeron on this entry
RSS2.0 Atom
Not signed in
Sign in

Powered by BlogBuilder
© MMXXII