Sunday, July 4, 2010
mod_jk Vs mod_proxy_http Vs mod_proxy_ajp
The best link I have ever read that gives a summary on when to use what - http://www.tomcatexpert.com/blog/2010/06/16/deciding-between-modjk-modproxyhttp-and-modproxyajp
NJoy!
Thursday, March 19, 2009
Parent Child Relationship - Hibernate
Parent Child Relationship - Hibernate
Inserting values in both parent and child table in Hibernate in a single session.save() command. You need not insert value in the parent table first and then get the ID and set it in the child and then insert it. You can do both at the same time. Below are the sample code snippets of the files used.
hbm.xml file:
<class name="com.sample.pojos.UserInfoBean" table="USER_INFO" lazy="false">
... other properties configured
<property name="firstName" type="java.lang.String" column="FIRST_NAME" />
<property name="lastName" type="java.lang.String" column="LAST_NAME" />
<bag cascade="all-delete-orphan" inverse="true" lazy="true" name="userDetailsBean" table="USER_DETAILS">
<key column="USER_INFO_ID"/>
<one-to-many class="com.sample.pojos.UserDetailsBean"/>
</bag>
</class>
<class name="com.sample.pojos.UserDetailsBean" table="USER_DETAILS" lazy="false">
... other properties configured
<property name="address" type="java.lang.String" column="ADDRESS" />
<property name="city" type="java.lang.String" column="CITY" />
<many-to-one cascade="none" class="com.sample.pojos.UserInfoBean" column="USER_INFO_ID" insert="true" name="userInfoBean" outer-join="false" update="true"/>
</class>
UserInfoBean.java
private List userDetailsBean;
... other properties
/**
* @return Returns the userDetailsBean.
*/
public List getUserDetailsBean() {
return userDetailsBean;
}
/**
* @param userDetailsBean The userDetailsBean to set.
*/
public void setUserDetailsBean(List userDetailsBean) {
this.userDetailsBean = userDetailsBean;
}
... getters and setters for other properties
[/sourcecode]
UserDetailsBean.java
[sourcecode language='java']
private UserInfoBean userInfoBean;
... other properties
/**
* @return Returns the userInfoBean.
*/
public UserInfoBean getUserInfoBean() {
return userInfoBean;
}
/**
* @param userInfoBean The userInfoBean to set.
*/
public void setUserInfoBean(UserInfoBean userInfoBean) {
this.userInfoBean = userInfoBean;
}
... getters and setters for other properties
Business class:
Transaction transaction = null;
UserInfoBean userInfoBean = new UserInfoBean();
... set the required properties
UserDetailsBean userDetailsBean = new UserDetailsBean();
... set the required properties
// Setting the parent class in the child class
userDetailsBean.setUserInfoBean(userInfoBean);
// List for storing the User Details Beans
List userDetailsList = new ArrayList();
// Adding the UserDetailsBean to the list
userDetailsList.add(userDetailsBean);
// Setting the list in the UserInfoBean
userInfoBean.setUserDetailsBean(userDetailsList);
try {
Session session = SessionManager.currentSession();
transaction = session.beginTransaction();
session.save(userInfoBean);
session.flush();
session.clear();
transaction.commit();
createUserStatus = true;
} catch (Exception e) {
transaction.rollback();
} finally {
SessionManager.closeSession();
}
Now in a single session.save() command, values gets inserted in both the parent and child table.
Hope this helps.
Monday, January 26, 2009
Wednesday, December 31, 2008
Continuous Build Integration
Developer checks work into version control
CC polls version control
CC triggers a build
CC captures logs and build artifacts
Examples: jar, war, javadoc, unit test report, code coverage report, code quality metrics
CC publishes results
Examples: send email, send instant message
<project name="connectfour">There is a cruisecontrol dashboard through which we can access the history of artifacts and build results and manage those.
<listeners>
<currentbuildstatuslistener file="logs/${project.name}/status.txt"/>
</listeners>
<bootstrappers>
<svnbootstrapper localWorkingCopy="projects/${project.name}" />
</bootstrappers>
<modificationset quietperiod="30">
<svn localWorkingCopy="projects/${project.name}"/>
</modificationset>
<schedule interval="300">
<ant anthome="apache-ant-1.7.0" buildfile="projects/${project.name}/build.xml"/>
</schedule>
<log>
<merge dir="projects/${project.name}/target/test-results"/>
</log>
<publishers>
<onsuccess>
<artifactspublisher dest="artifacts/${project.name}" file="projects/${project.name}/target/${project.name}.jar"/>
</onsuccess>
</publishers>
</project>
</cruisecontrol>
Monday, November 10, 2008
CSS and JS compression
It would be a wise option to compress the CSS and JS files to make download of these on the fly much faster.
1) GZIP compression
2) Remove unwanted space, line feed characters in JS.
3) Use smaller variable names
4) Remove comments
For (1) - Most of the application servers come with option of enabling compression for HTTP and HTTPS. For example in Tomcat you can do it by setting in the server.xml
...
<connector acceptcount="100" connectiontimeout="60000" disableuploadtimeout="true"
port="9014" redirectport="8944" scheme="https" proxyport="443" compression="on"
compressablemimetype="text/html,text/xml,text/plain,text/css,text/javascript">
...
Having 2, 3 and 4 done on the code base will make it ugly and not readable. There are lots of open source tool which can help as they does all these during build time when creating the achieves.For example one such tool would be Yahoo UI compressor - it has a easy maven plugin as well - click here for more details on usage.
Thursday, May 10, 2007
Including HTML Tags/codes in Blog Post
NOTE: Instead of "amp" use the "&" symbol, i have given " amp "here for reperesentation.
Applying Styles for File Button
1.You can find out the code behind of this File button and can implement that procedure in Onclick of this image button.
2.You can have an image Button over a File Button and you can invoke the Click event of the File button from the onclick event of this image buttton. For this you have to play with the z-index property.
we will have a look at the second method, as the first one is very simple.
How to do this?
Change the z-index of the File Button, make it as negative(or a lesser value than image button). I have included the code here, check it out here
<script type=”text/javascript”>
function clickBrowse()
{
document.getElementById(’openssme’).click()
}
</script<
<style type=”text/css”<
input.hide
{
position:relative;
left:-225px;
z-index: -1;
width:0px;
border-width:0px;
}
input.red
{
position:relative;
background-color:#cc0000;
font-weight:bold;
color:#ffffff;
z-index:100;
width:75px;
height:20px;
font-size:10px;
}
</style>
<!–[if IE]>
<style type=”text/css”>
input.hide
{
position:relative;
visibility:hidden;
left:-83px;
z-index: -1;
width:0px;
border-width:0px;
}
</style>
<![endif]–>
<img src=”btn_browse.gif” class=”red” id=”pseudobutton” onClick=”clickBrowse();” />
<input type=”file” class=”hide” id=”openssme”>
We have to handle IE and FF seperately, so a code for IE is placed seperately in this.
I thank Nirmal, for helping me out in this.