Skip to content
Permalink
Browse files
Merge branch 'yoko_auxilliary_stream_format' into 'ibm-trunk'
Yoko auxilliary stream format

See merge request !54
  • Loading branch information
joe-chacko committed Jul 9, 2015
2 parents b691809 + 8ca5714 commit 3ebe0147f2ed236cf9718760e4281c5ffdd18513
Showing 5 changed files with 228 additions and 0 deletions.
@@ -28,6 +28,9 @@
import org.apache.yoko.orb.util.AutoLock;
import org.apache.yoko.orb.util.AutoReadWriteLock;
import org.apache.yoko.orb.util.GetSystemPropertyAction;
import org.apache.yoko.orb.yasf.YasfClientInterceptor;
import org.apache.yoko.orb.yasf.YasfIORInterceptor;
import org.apache.yoko.orb.yasf.YasfServerInterceptor;
import org.apache.yoko.util.osgi.ProviderLocator;
import org.omg.CORBA.OBJECT_NOT_EXIST;

@@ -289,6 +292,16 @@ private void initialize(org.omg.CORBA.StringSeqHolder args, String orbId,
org.apache.yoko.orb.OB.Assert._OB_assert(ex);
}

//
// Install interceptors for Yoko Auxilliary Stream Format
//
try {
piManager.addIORInterceptor(new YasfIORInterceptor(), true);
piManager.addClientRequestInterceptor(new YasfClientInterceptor());
piManager.addServerRequestInterceptor(new YasfServerInterceptor());
} catch (org.omg.PortableInterceptor.ORBInitInfoPackage.DuplicateName ex) {
org.apache.yoko.orb.OB.Assert._OB_assert(ex);
}
//
// Install interceptors for Custom Marshal Stream Format negotiation
//
@@ -0,0 +1,71 @@
package org.apache.yoko.orb.yasf;

import java.util.BitSet;

import org.omg.IOP.ServiceContext;
import org.omg.IOP.TaggedComponent;

public enum Yasf {
;

// TODO - Get ids from OMG assigned for these values
public static final int TAG_YOKO_AUXILLIARY_STREAM_FORMAT = 0xeeeeeeee;
public static final int YOKO_AUXIllIARY_STREAM_FORMAT_SC = 0xeeeeeeee;

public final int itemIndex;

private Yasf(int itemIndex) {
this.itemIndex = itemIndex;
}

public boolean isSet(BitSet items) {
return items.get(itemIndex);
}

public static Builder build() {
return new BuilderImpl();
}

public static BitSet readData(byte[] data) {
return BitSet.valueOf(data);
}

public interface Builder {
public Builder set(Yasf... items);
public Builder clear(Yasf... items);
public TaggedComponent tc();
public ServiceContext sc();
}

private static final class BuilderImpl implements Builder {
private final BitSet bits = new BitSet();

BuilderImpl() {}

@Override
public Builder set(Yasf... items) {
for (Yasf item: items) {
bits.set(item.itemIndex);
}
return this;
}

@Override
public Builder clear(Yasf... items) {
for (Yasf item: items) {
bits.clear(item.itemIndex);
}
return this;
}

@Override
public TaggedComponent tc() {
return new TaggedComponent(TAG_YOKO_AUXILLIARY_STREAM_FORMAT, bits.toByteArray());
}

@Override
public ServiceContext sc() {
return new ServiceContext(YOKO_AUXIllIARY_STREAM_FORMAT_SC, bits.toByteArray());
}
}
}
@@ -0,0 +1,53 @@
package org.apache.yoko.orb.yasf;

import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import org.omg.CORBA.LocalObject;
import org.omg.PortableInterceptor.ClientRequestInfo;
import org.omg.PortableInterceptor.ClientRequestInterceptor;
import org.omg.PortableInterceptor.ForwardRequest;

public class YasfClientInterceptor extends LocalObject implements ClientRequestInterceptor {
private static final String NAME = YasfClientInterceptor.class.getName();

@Override
public void send_request(ClientRequestInfo ri) throws ForwardRequest {
ri.add_request_service_context(Yasf.build().sc(), false);
}

@Override
public void send_poll(ClientRequestInfo ri) {
}

@Override
public void receive_reply(ClientRequestInfo ri) {
}

@Override
public void receive_exception(ClientRequestInfo ri) throws ForwardRequest {
}

@Override
public void receive_other(ClientRequestInfo ri) throws ForwardRequest {
}

@Override
public String name() {
return NAME;
}

@Override
public void destroy() {
}

private void readObject(ObjectInputStream ios) throws IOException {
throw new NotSerializableException(NAME);
}

private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException(NAME);
}
}
@@ -0,0 +1,36 @@
package org.apache.yoko.orb.yasf;

import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import org.omg.CORBA.LocalObject;
import org.omg.PortableInterceptor.IORInfo;
import org.omg.PortableInterceptor.IORInterceptor;

public class YasfIORInterceptor extends LocalObject implements IORInterceptor {
private static final String NAME = YasfIORInterceptor.class.getName();

@Override
public void establish_components(IORInfo info) {
info.add_ior_component(Yasf.build().tc());
}

@Override
public String name() {
return NAME;
}

@Override
public void destroy() {
}

private void readObject(ObjectInputStream ios) throws IOException {
throw new NotSerializableException(NAME);
}

private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException(NAME);
}
}
@@ -0,0 +1,55 @@
package org.apache.yoko.orb.yasf;

import java.io.IOException;
import java.io.NotSerializableException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;

import org.omg.CORBA.LocalObject;
import org.omg.PortableInterceptor.ForwardRequest;
import org.omg.PortableInterceptor.ServerRequestInfo;
import org.omg.PortableInterceptor.ServerRequestInterceptor;

public class YasfServerInterceptor extends LocalObject implements ServerRequestInterceptor {
private static final String NAME = YasfServerInterceptor.class.getName();

@Override
public void receive_request_service_contexts(ServerRequestInfo ri) throws ForwardRequest {
}

@Override
public void receive_request(ServerRequestInfo ri) throws ForwardRequest {
}

@Override
public void send_reply(ServerRequestInfo ri) {
ri.add_reply_service_context(Yasf.build().sc(), false);
}

@Override
public void send_exception(ServerRequestInfo ri) throws ForwardRequest {
ri.add_reply_service_context(Yasf.build().sc(), false);
}

@Override
public void send_other(ServerRequestInfo ri) throws ForwardRequest {
ri.add_reply_service_context(Yasf.build().sc(), false);
}

@Override
public String name() {
return NAME;
}

@Override
public void destroy() {
}

private void readObject(ObjectInputStream ios) throws IOException {
throw new NotSerializableException(NAME);
}

private void writeObject(ObjectOutputStream oos) throws IOException {
throw new NotSerializableException(NAME);
}
}

0 comments on commit 3ebe014

Please sign in to comment.