use of com.swiftmq.tools.versioning.Versionable in project swiftmq-ce by iitsoftware.
the class JNDISwiftletImpl method createStatics.
private void createStatics(EntityList staticList) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "create static objects ...");
String[] s = staticList.getEntityNames();
if (s != null) {
for (int i = 0; i < s.length; i++) {
try {
DataByteArrayOutputStream dos = new DataByteArrayOutputStream();
DestinationFactory.dumpDestination(getStaticQueue(s[i]), dos);
Versionable versionable = new Versionable();
versionable.addVersioned(-1, new Versioned(-1, dos.getBuffer(), dos.getCount()), "com.swiftmq.jms.DestinationFactory");
registerJNDIObject(s[i], versionable);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "create static objects for '" + s[i] + "', exception=" + e);
}
}
} else if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "no static objects defined");
staticList.setEntityAddListener(new EntityChangeAdapter(null) {
public void onEntityAdd(Entity parent, Entity newEntity) throws EntityAddException {
String name = newEntity.getName();
try {
DataByteArrayOutputStream dos = new DataByteArrayOutputStream();
DestinationFactory.dumpDestination(getStaticQueue(name), dos);
Versionable versionable = new Versionable();
versionable.addVersioned(-1, new Versioned(-1, dos.getBuffer(), dos.getCount()), "com.swiftmq.jms.DestinationFactory");
registerJNDIObject(name, versionable);
} catch (Exception e) {
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "onEntityAdd (statics) for '" + name + "', exception=" + e);
throw new EntityAddException(e.getMessage());
}
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "onEntityAdd (statics): static object=" + name);
}
});
staticList.setEntityRemoveListener(new EntityChangeAdapter(null) {
public void onEntityRemove(Entity parent, Entity delEntity) throws EntityRemoveException {
String name = delEntity.getName();
deregisterJNDIObject(name);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(getName(), "onEntityRemove (statics): static=" + name);
}
});
}
use of com.swiftmq.tools.versioning.Versionable in project swiftmq-ce by iitsoftware.
the class QueueJNDIProcessor method run.
public void run() {
try {
t.commit();
try {
Versionable versionable = Versionable.toVersionable(msg);
int version = versionable.selectVersions(JNDISwiftletImpl.VERSIONS);
switch(version) {
case 400:
{
JNDIRequest r = (JNDIRequest) versionable.createVersionedObject();
com.swiftmq.impl.jndi.standard.v400.RequestVisitor visitor = new com.swiftmq.impl.jndi.standard.v400.RequestVisitor(ctx, (QueueImpl) msg.getJMSReplyTo(), true);
r.accept(visitor);
}
break;
default:
throw new Exception("Invalid version: " + version);
}
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e);
ctx.logSwiftlet.logError(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e);
}
msg = null;
if (closed)
return;
t = receiver.createTransaction(false);
t.registerMessageProcessor(this);
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "QueueJNDIProcessor: exception occurred: " + e + ", EXITING!");
}
}
use of com.swiftmq.tools.versioning.Versionable in project swiftmq-ce by iitsoftware.
the class TopicJNDIProcessor method run.
public void run() {
try {
t.commit();
try {
Versionable versionable = Versionable.toVersionable(msg);
int version = versionable.selectVersions(JNDISwiftletImpl.VERSIONS);
switch(version) {
case 400:
{
JNDIRequest r = (JNDIRequest) versionable.createVersionedObject();
com.swiftmq.impl.jndi.standard.v400.RequestVisitor visitor = new com.swiftmq.impl.jndi.standard.v400.RequestVisitor(ctx, (QueueImpl) msg.getJMSReplyTo());
r.accept(visitor);
}
break;
default:
throw new Exception("Invalid version: " + version);
}
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e);
ctx.logSwiftlet.logError(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e);
}
msg = null;
if (closed)
return;
t = receiver.createTransaction(false);
t.registerMessageProcessor(this);
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.jndiSwiftlet.getName(), "TopicJNDIProcessor: exception occurred: " + e + ", EXITING!");
}
}
use of com.swiftmq.tools.versioning.Versionable in project swiftmq-ce by iitsoftware.
the class QueueManagerImpl method registerJNDI.
private void registerJNDI(String name, QueueImpl queue) {
try {
String localName = stripLocalName(name);
DataByteArrayOutputStream dos = new DataByteArrayOutputStream();
DestinationFactory.dumpDestination(queue, dos);
Versionable versionable = new Versionable();
versionable.addVersioned(-1, new Versioned(-1, dos.getBuffer(), dos.getCount()), "com.swiftmq.jms.DestinationFactory");
ctx.jndiSwiftlet.registerJNDIObject(name, versionable);
registerJNDIAlias(localName, name);
} catch (IOException e) {
e.printStackTrace();
}
}
use of com.swiftmq.tools.versioning.Versionable in project swiftmq-ce by iitsoftware.
the class ClusterMetricSubscriber method run.
public void run() {
try {
t.commit();
try {
Versionable versionable = Versionable.toVersionable(msg);
versionable.setClassLoader(getClass().getClassLoader());
int version = versionable.selectVersions(QueueManagerImpl.VERSIONS);
switch(version) {
case 700:
{
ClusteredQueueMetricCollection cmc = (ClusteredQueueMetricCollection) versionable.createVersionedObject();
List list = cmc.getClusteredQueueMetrics();
if (list != null) {
for (int i = 0; i < list.size(); i++) {
ClusteredQueueMetric cm = (ClusteredQueueMetric) list.get(i);
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/run, cm=" + cm);
DispatchPolicy dp = ctx.dispatchPolicyRegistry.get(cm.getClusteredQueueName());
if (dp != null)
dp.addMetric(cmc.getRouterName(), cm);
}
}
}
break;
default:
throw new Exception("Invalid version: " + version);
}
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/exception occurred: " + e);
ctx.logSwiftlet.logError(ctx.queueManager.getName(), toString() + "/exception occurred: " + e);
}
msg = null;
if (closed)
return;
t = receiver.createTransaction(false);
t.registerMessageProcessor(this);
} catch (Exception e) {
if (closed)
return;
if (ctx.traceSpace.enabled)
ctx.traceSpace.trace(ctx.queueManager.getName(), toString() + "/exception occurred: " + e + ", EXITING!");
}
}
Aggregations