Friday, March 30, 2012

Eheheh just jocking with interfaces

Any other idea about how to expose a component?

ui... rest... ws... ejb...

package net.sixdeex.jpc.services;

import javax.ejb.Local;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import javax.ejb.TransactionAttribute;
import javax.ejb.TransactionAttributeType;
import javax.jws.WebMethod;
import javax.jws.WebParam;
import javax.jws.WebParam.Mode;
import javax.jws.WebResult;
import javax.jws.WebService;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import net.sixdeex.jpc.CalculateDescendCommand;
import net.sixdeex.jpc.framework.CalculateCommand;
import net.sixdeex.jpc.framework.OutputData;

@Path("/x737")
@Produces(MediaType.APPLICATION_JSON)
@Stateless
@Local(X737Calculation.class)
@Remote(RemoteX737Calculation.class)
@TransactionAttribute(TransactionAttributeType.SUPPORTS)
@WebService
public class X737CalculationBean implements RemoteX737Calculation {

    @GET
    @Path("/descend/{from}/{to}")
    @Override
    @WebMethod(operationName = "descend")
    public @WebResult(name = "outputData")
    OutputData descend(
            @PathParam("from") @WebParam(name = "fromLevel", mode = Mode.IN) int fromLevel,
            @PathParam("to") @WebParam(name = "toLevel", mode = Mode.IN) int toLevel) {

        final CalculateCommand calculateDescend = new CalculateDescendCommand(
                null, fromLevel, toLevel);

        return calculateDescend.execute();
    }
}

Friday, March 2, 2012

maven wsimport and deploy phase problem when behind a firewall

I did a client module that perform wsgen to get the WSDL from the server module and then the wsimport to create the client jar.

Everything works up to the install phase but fails in the deploy phase... the behavior is that mvn succed in uploading the jar but fails to upload the pom with the following error:

Failed to deploy artifacts: Could not find artifact ... in ...

To fix the problem it is required to unset the proxy when calling the wsimport goal with

<httpproxy>::</httpproxy>

as shown in the following pom:

<?xml version="1.0" encoding="UTF-8"?>

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <parent>
        <groupId>my.group</groupId>
        <artifactId>parent</artifactId>
        <version>0.1-SNAPSHOT</version>
    </parent>

    <modelVersion>4.0.0</modelVersion>

    <groupId>my.group.ws</groupId>
    <artifactId>ws-client</artifactId>
    <version>0.1-SNAPSHOT</version>

    <name>WS client</name>
    <packaging>jar</packaging>

    <dependencies>
        <dependency>
            <groupId>my.group.ws</groupId>
            <artifactId>ws-server</artifactId>
            <version>0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>com.sun.xml.ws</groupId>
            <artifactId>jaxws-rt</artifactId>
            <version>2.2.6</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>

    <build>
        <sourceDirectory>${project.build.directory}/generated-sources/wsimport</sourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>2.3.2</version>
                <configuration>
                    <source>1.6</source>
                    <target>1.6</target>
                    <compilerArguments>
                        <endorseddirs>${project.build.directory}/endorsed</endorseddirs>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.jvnet.jax-ws-commons</groupId>
                <artifactId>jaxws-maven-plugin</artifactId>
                <version>2.2</version>
                <executions>
                    <execution>
                        <id>wsgen</id>
                        <phase>initialize</phase>
                        <goals>
                            <goal>wsgen</goal>
                        </goals>
                        <configuration>
                            <sei>my.group.ws.sei.SEIClass</sei>
                            <genWsdl>true</genWsdl>
                            <keep>false</keep>
                        </configuration>
                    </execution>
                    <execution>
                        <id>wsimport</id>
                        <goals>
                            <goal>wsimport</goal>
                        </goals>
                        <configuration>
                            <wsdlDirectory>${project.build.directory}/generated-sources/wsdl</wsdlDirectory>
                            <sourceDestDir>${project.build.directory}/generated-sources/wsimport</sourceDestDir>
                            <keep>false</keep>
                            <httpproxy>::</httpproxy>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-jar-plugin</artifactId>
                <version>2.4</version>
                <configuration>
                    <excludes>
                        <exclude>my/group/ws/jaxws/*</exclude>
                    </excludes>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-dependency-plugin</artifactId>
                <version>2.3</version>
                <executions>
                    <execution>
                        <phase>validate</phase>
                        <goals>
                            <goal>copy</goal>
                        </goals>
                        <configuration>
                            <outputDirectory>${project.build.directory}/endorsed</outputDirectory>
                            <silent>true</silent>
                            <artifactItems>
                                <artifactItem>
                                    <groupId>javax.xml.bind</groupId>
                                    <artifactId>jaxb-api</artifactId>
                                    <version>2.2.4</version>
                                    <type>jar</type>
                                </artifactItem>
                                <artifactItem>
                                    <groupId>javax.xml.ws</groupId>
                                    <artifactId>jaxws-api</artifactId>
                                    <version>2.2.8</version>
                                    <type>jar</type>
                                </artifactItem>
                            </artifactItems>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

Tuesday, August 23, 2011

Identifying which Java Thread is consuming most CPU

A nice way to debug cpu usage by threads in a java process

http://code.nomad-labs.com/2010/11/18/identifying-which-java-thread-is-consuming-most-cpu/

Sunday, May 8, 2011

openSuse 11.4, broadcom bcm4312 and Tumbleweed

it works out of the box after adding the the Packman repo and installing

broadcom_wl and broadcom_wl_kmp_desktop

Kindle whispernet connection

it's possible to fix kindle connection problems to whispernet following the amazon customer service directives:

Visit your Kindle's Settings screen by selecting that option from the Home screen menu. When you're on the Settings screen, type 311 on Kindle's keyboard.

When prompted to switch wireless providers, select "OK" to see a list of providers in your area. Please allow up to two minutes for Kindle to complete a search of available wireless providers.

Select a carrier from the list and wait for Kindle to return to the Setting screen and attempt to connect to Whispernet. If after two minutes you are still unable to connect or your signal strength does not improve, please repeat the steps above and select a different carrier from the list.

it worked on my kindle 2nd generation