How to Generate Serializable JAXB Classes
<?xml version="1.0" encoding="UTF-8"?>
<jaxb:bindings version="2.1" xmlns:jaxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema" schemaLocation="sample.xsd">
<jaxb:globalBindings>
<jaxb:serializable uid="1" />
</jaxb:globalBindings>
</jaxb:bindings>
OSGi Extension Bundles
A fairly unknown feature.
http://blog.meschberger.ch/2008/10/osgi-bundles-require-classes-from.html
http://blog.meschberger.ch/2008/10/osgi-framework-extension-as-maven.html
Refer to the 3.15 section of the spec.
How to Deserialize Objects with Apache Camel 2.8
import org.apache.camel.builder.RouteBuilder;
public final class SampleRouteBuilder extends RouteBuilder {
@Override
public void configure() {
from(...).unmarshal().serialization();
}
}
If you need to unmarshal an object that isn’t available to the camel-core bundle, you need enabling dynamic-import for it with the dev:dynamic-import command or using a custom processor.
How to Serialize Objects with Apache Camel 2.8
import org.apache.camel.builder.RouteBuilder;
public final class SampleRouteBuilder extends RouteBuilder {
@Override
public void configure() {
from(...).marshal().serialization();
}
}
How to Attach an Object to a Task in jBPM 5.1
import static java.lang.System.out;
import java.io.ByteArrayOutputStream;
import java.io.ObjectOutputStream;
import java.util.Date;
import org.drools.SystemEventListenerFactory;
import org.jbpm.task.AccessType;
import org.jbpm.task.Attachment;
import org.jbpm.task.Content;
import org.jbpm.task.User;
import org.jbpm.task.service.TaskClient;
import org.jbpm.task.service.mina.MinaTaskClientConnector;
import org.jbpm.task.service.mina.MinaTaskClientHandler;
import org.jbpm.task.service.responsehandlers.BlockingAddAttachmentResponseHandler;
public final class JbpmSample {
public static void main(final String[] args) throws Exception {
final TaskClient client = new TaskClient(new MinaTaskClientConnector("SampleClient", new MinaTaskClientHandler(SystemEventListenerFactory.getSystemEventListener())));
if (client.connect("localhost", 9123)) {
final BlockingAddAttachmentResponseHandler handler = new BlockingAddAttachmentResponseHandler();
final Attachment attachment = new Attachment();
attachment.setAccessType(AccessType.Inline); // required
attachment.setAttachedAt(new Date(System.currentTimeMillis())); // required
attachment.setAttachedBy(new User("krisv")); // required
attachment.setContentType(""); // required
attachment.setName(""); // required
final ByteArrayOutputStream baos = new ByteArrayOutputStream();
final ObjectOutputStream oos = new ObjectOutputStream(baos);
oos.writeObject("Simples Assim");
baos.close();
final Content content = new Content();
content.setContent(baos.toByteArray()); // required
client.addAttachment(1, attachment, content, handler);
out.println(handler.getAttachmentId());
client.disconnect();
}
}
}
How to Create a Macro in FreeMarker 2.3.18
<#macro sample param1 param2>
<Item>
<Field1>${param1}</Field1>
<Field2>${param2}</Field2>
</Item>
</#macro>
<?xml version="1.0" encoding="UTF-8"?>
<List>
<#list list as item>
<@sample param1="${...}" param2="SampleTemplateMethodModel"?new()() />
</#list>
</List>
http://freemarker.sourceforge.net/docs/ref_directive_macro.html
Improvement to jBPM 5.2
The OrderColumn annotation would be a nice addition to the Human Task Service classes.
Serializable vs. Externalizable
According to the Java Object Serialization Specification 6.0, for Externalizable objects, only the identity of the class of the object is saved by the container; the class must save and restore the contents.
http://docs.oracle.com/javase/6/docs/api/java/io/Serializable.html
http://docs.oracle.com/javase/6/docs/api/java/io/Externalizable.html
