Wednesday, February 29, 2012

Dynamic Class Loading + Reloading

http://tutorials.jenkov.com/java-reflection/dynamic-class-loading-reloading.html


an article:

Recoverable Class Loaders for a Fast Restart of Java Applications

Vladimir Nikolov, RĂ¼diger Kapitza and Franz J. Hauck



related:

HOW TO: Bootstrap Java programs in isolated classloaders

http://blog.markturansky.com/archives/21

Watching a Directory for Changes

http://docs.oracle.com/javase/tutorial/essential/io/notification.html

Saturday, February 25, 2012

Burkley Online Courses

http://www.coursera.org/

Natural Language Processing

http://www.cs.colorado.edu/~martin/slp.html
http://nlp.stanford.edu/IR-book/
http://nlp.stanford.edu/fsnlp/
http://www.nltk.org/book

Wednesday, January 11, 2012

JAXB

old pieces of code:

public static com.harrods.hrc.ws.client.mapping.getDetails.Member parseGetDetailsResult(String resultFromWS)
throws JAXBException
{
if ( resultFromWS == null ) return null;
resultFromWS = "" + resultFromWS + "";
JAXBContext jaxbContext = JAXBContext.newInstance( "com.harrods.hrc.ws.client.mapping.getDetails" );
ByteArrayInputStream input = new ByteArrayInputStream (resultFromWS.getBytes());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
com.harrods.hrc.ws.client.mapping.getDetails.Member getDetailsResult =
(com.harrods.hrc.ws.client.mapping.getDetails.Member)
unmarshaller.unmarshal(input);
return getDetailsResult;
}

//another impl
if ( memberAsString == null ) throw new Exception("member is null");
memberAsString = "" + memberAsString + "";

JAXBContext jaxbContext = JAXBContext.newInstance( com.harrods.hrc.ws.client.mapping.enrol.response.Member.class );

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader stringReader = new StringReader(memberAsString);
return
(com.harrods.hrc.ws.client.mapping.enrol.response.Member)
unmarshaller.unmarshal(stringReader);


//
JAXBContext jaxbContext = JAXBContext.newInstance(
com.harrods.hrc.ws.client.mapping.enrol.request.RequestData.class
);

Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING , "UTF-8");
//setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

StringWriter stringWriter = new StringWriter();
marshaller.marshal(enrolRequestData, stringWriter);
return stringWriter.toString();


//
EndpointReference targetEPR = new EndpointReference(
wsEndpoint
);

Options options = new Options();
//GRIPS MX Web Service endpoint
options.setTo(targetEPR);
// Increase the time out when sending large attachments
options.setTimeOutInMilliSeconds(timeout);
options.setTo(targetEPR);
//GRIPS MX Web Service IssueCheque operation
options.setAction("http://jetsystems.com/GRIPSMX/IssueCheque");

ServiceClient sender = new ServiceClient(); //default context
sender.setOptions(options);
OperationClient mepClient = sender
.createClient(ServiceClient.ANON_OUT_IN_OP);

MessageContext messageContext = new MessageContext();

SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();

SAXOMBuilder saxomBuilder = new SAXOMBuilder();
JAXBContext jaxbContext =
JAXBContext.newInstance("com.jetsystems.gripsmx.ws");
Marshaller marshaller = jaxbContext.createMarshaller();

marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
new NamespacePrefixMapperImpl());

com.jetsystems.gripsmx.ws.ChequeRequest chequeRequest =
generateChequeRequest(
country,
shop,
tillId,
operatorId,
posBasket,
dataEntry,
basketWsProperties
);
marshaller.marshal(chequeRequest, saxomBuilder);
OMElement issueChequeRequest = saxomBuilder.getRootElement();
issueChequeRequest.setLocalName("issueChequeRequest");

soapEnvelope.getBody().addChild(issueChequeRequest);

messageContext.setEnvelope(soapEnvelope);

mepClient.addMessageContext(messageContext);
mepClient.execute(true);
MessageContext response = mepClient
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPBody soapBody = response.getEnvelope().getBody();

//try to unmarshal the response
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

JAXBElement jaxbElement =
(JAXBElement)unmarshaller.unmarshal(
soapBody.getFirstElement().getXMLStreamReader());
com.jetsystems.gripsmx.ws.Cheque cheque =
(com.jetsystems.gripsmx.ws.Cheque)
jaxbElement.getValue();

logger.debug("issued cheque = " + cheque);
return cheque;

//

Monday, January 9, 2012

BPEL

http://www.theserverside.com/news/1364554/BPEL-and-Java

Saturday, January 7, 2012

Java Networking and Cryptography

books:
1)

Beginning Cryptography with Java

David Hook
Wiley Publishing, Inc.
recommended by bouncycastle
2) Esmond Pitt - Fundamental Networking in Java, Springer 2006 - great book

Qarbon ViewletBuilder

http://www.qarbon.com/presentation-software/viewletbuilder/