Archive for the 'IT' Category

Feb 07 2008

20 questions

Published by under AI

I have just found out an interesting webpage: http://www.20q.net/

It’s sort of an expert system, which is reasoning based on human’s answer given for specific questions. Questions are quite generic. While the system is self-learning, the more people play the game, the more accurate results are.

Based on the authors’ information the accuracy is about 80%. Check it out and have fun!

No responses yet

Feb 05 2008

Code quality ;-)

Published by under IT

No responses yet

Dec 17 2007

Netbeans 6.0 Mobility – FileBrowser

Published by under IT,Java

Netbeans 6.0 gives really nice support for developing Java Micro Edition applications. It provides some useful classes which are not part of standard JME profiles.
One of them is class: org.netbeans.microedition.lcdui.pda.FileBrowser.
It provides file browser for mobile phone implementing JSR-75. It looks fine but there is a bug in it. Method getSelectedFileURL() returns incorrect value, e.g.: file:///E:/myfolder//myfile.mp3 instead of file:///E:/myfolder/myfile.mp3
Removing manually last extra slash fixes the problem.

One response so far

Nov 07 2007

Google’s Krakow Open House

Published by under IT

Today Google opened its office in Krakow for non-googlers.

There was a TechTalk given by Michal Zalewski on “The evolution of web security: The unexpected pitfalls of web application programming”. It was mainly about cross-site-scripting techniques and browsers security gaps. The event was located at AGH University of Science and Technology.

After it every attendee could visit Google’s office in Krakow. It looks nice… rather like a big apartment with bunch of LCD monitors than usual office space. The office is located at Krupnicza Street.



View Larger Map

Google is planning to expand Krakow’s office to 80 people till the end of 2008.

No responses yet

Sep 25 2007

Spring remoting quickstart

Published by under IT,Java

I have spent a lot of time on configuring Spring remoting properly (mostly because of problems with DTD).
To expose business logic via for example XFire Web Services we have to define context and listeners in web.xml, example:

<?xml version=”1.0″ encoding=”ISO-8859-1″?>
<!DOCTYPE web-app
PUBLIC “-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN”

“http://java.sun.com/dtd/web-app_2_3.dtd”>
<web-app>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext.xml</param-value>
</context-param>
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>/WEB-INF/log4j.properties</param-value>
</context-param>
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

</listener>
<servlet>
<servlet-name>XFireServlet</servlet-name>
<servlet-class>org.codehaus.xfire.spring.XFireSpringServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/servlet/XFireServlet/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>XFireServlet</servlet-name>
<url-pattern>/services/*</url-pattern>
</servlet-mapping>
</web-app>

Configuration of beans that are going to be exposed via WS is stored in separate file, in this case in applicationContext.xml. Example of the content of the file:

<?xml version=”1.0″ encoding=”UTF-8″?>
<!DOCTYPE beans PUBLIC “-//SPRING//DTD BEAN//EN” “http://www.springframework.org/dtd/spring-beans-2.0.dtd”>
<beans>
<bean class=”org.springframework.web.servlet.handler.SimpleUrlHandlerMapping”>
<property name=”urlMap”>
<map>
<entry key=”/WorkflowRegister”>
<ref bean=”workflowRegister”/>
</entry>
</map>
</property>
</bean>
<bean id=”workflowRegister” class=”org.codehaus.xfire.spring.remoting.XFireExporter”>
<property name=”serviceFactory”>
<ref bean=”xfire.serviceFactory”/>
</property>
<property name=”xfire”>
<ref bean=”xfire”/>
</property>
<property name=”serviceBean”>
<ref bean=”worklfowRegisterBean”/>
</property>
<property name=”serviceClass”>
<value>pl.edu.agh.gemini.adds.core.IWorkflowRegister</value>
</property>
</bean>
<bean id=”worklfowRegisterBean” class=”pl.edu.agh.gemini.adds.core.WorkflowRegister” factory-method=”getInstance” />
<import resource=”classpath:org/codehaus/xfire/spring/xfire.xml”/>
</beans>

As you can see defining new WS which is based on already implemented bean requires just few lines of XML. Business logic is totally separated from the way of exposing it. No changes are required in logic to expose it as Web Service! Also changing transport layer from XFire to e.g. Burlap/Hessian/RMI is just a matter of configuration in those two files.

Dependencies for Spring remoting (part of Maven pom.xml):

<dependencies>
<dependency>
<groupId>pl.edu.agh.gemini.adss</groupId>
<artifactId>adsscore</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>pl.edu.agh.gemini.adss</groupId>
<artifactId>adsscoreapi</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-remoting</artifactId>
<version>2.0.6</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-jaxb2</artifactId>
<version>1.2-RC</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-spring</artifactId>
<version>1.2-RC</version>
</dependency>
<dependency>
<groupId>org.codehaus.xfire</groupId>
<artifactId>xfire-java5</artifactId>
<version>1.2-RC</version>
</dependency>
</dependencies>

Application can be simply deployed as war file in servlet container (e.g. Tomcat), no J2EE application server is required.

Have fun with Spring remoting!

No responses yet

Jun 21 2007

KDG.NET

Published by under .NET,IT

Vayron was presented on KDG.NET meeting (Cracow .NET Developers Group).

Some of the members were interested in our project ;-) And I have wone nice computer mouse from Microsoft, so the meeting was quite successful ;-)

KDG.NET website (in Polish): http://www.grupanet.krakow.pl/

No responses yet

May 25 2007

Failure

Published by under .NET,IT


We haven’t won ;-( Congratulations to our mates from Poznan University of Technology. Top 2 places in the cup.

I would like to thank to: Lukasz Pobereznik, Agnieszka Zielinska, Jakub Jarzabek, Leszek Siwik, Pawel Krainski and Marek Naborczyk for participating in vayron.net project.
It was a great pleasure to work with you.We are considering taking part in Imagine Cup next year. Maybe it will be more successful than 2006 and 2007…

No responses yet

May 16 2007

Imagine Cup 2007

Published by under .NET,IT

We are going to participate in Imagine Cup national finals in Warsaw next week!
Our project Vayron.NET is competing in category ‘Software Design’.

If you are curious please visit http://vayron.net and join the game.

Keep your fingers crossed!

No responses yet

May 04 2007

Injecting EJB 3.0 beans into Struts 2.0

Published by under IT,Java

EJB 3.0 provides easy bean injection. While developing web layer in Struts 2.0 you can use similar mechanism as well. Struts 2.0 is using Spring libraries for implementing Inversion of Control design pattern.

EJB 3.0 is based on using Java 1.5 annotations. It simplifies deployment process.

Let define example Session Bean.

@Stateless(mappedName=”ejb/EmployeeManager”)
public class EmployeeManagerSB implements IEmployeeManager {

public Long createAccount(String loginName) {
// Implementation of creating an account…
}

}

It implements interface:

@Remote
@Local

public interface IEmployeeManager {

Long createAccount(String loginName);

}

To use EmployeeManager session bean in Struts 2.0 reference to this object has to be retrieved.

Let define Struts action class which will use EmployeeManager session bean.

@Validation()
public class NewEmployeeAction extends ActionSupport {

private IEmployeeManager employeeManager;
private String loginName;
private long id;
private String redirectURL;

public String execute() throws Exception {
Long id = this.employeeManager.createAccount(this.loginName);
this.setId(id.longValue());
return SUCCESS;
}

public IEmployeeManager getEmployeeManager() {
return employeeManager;
}

public void setEmployeeanager(IEmployeeManager employeeManager) {
this.employeeManager = employeeManager;
}

public String getLoginName() {
return loginName;
}

@RequiredStringValidator(message = “Please enter a login name”, trim = true)
public void setLoginName(String loginName) {
this.loginName = loginName;
}

public long getId() {
return id;
}

public String getRedirectURL() {
return redirectURL;
}

public void setRedirectURL(String redirectURL) {
this.redirectURL = redirectURL;
}

}

Framework is taking care of injecting proper object while creating this action object. In Struts 2.0 the only thing that has to be done to do this is defining it in applicationContext.xml configuration file.

<jee:jndi-lookup id=”employeeManager” name=”ejb/EmployeeManager“>

<bean id=”newEmployeeAction” class=”pl.edu.agh.sius2007.jspynet.struts.NewEmployeeAction”>
<property name=”employeeManager” ref=”employeeManager”>
</bean>

The only configuration in Struts is defining two beans.

  • employeeManager which will be retrieved from JNDI;
  • newEmployeeAction which is Struts action.

employeeManager bean will be retrieved automatically and injected into newEmployeeAction.

No responses yet

« Prev