使用Java进行CORBA编程-JacORB-Notification Service(2)

上一篇介绍了CORBA的NotificationService以及如何来使用NotificationService。
上一篇 使用Java进行CORBA编程-JacORB-Notification Service

下面提供使用JacORB的NotificatoinService的一个例程,运行此例子需要启动NameService,
启动方法和例程的启动方法见  使用Java进行CORBA编程-JacORB-入门

另外,还需要启动NotificatoinService,在Windows上可以到JacORB的安装目录下的bin,使用下面的脚本来启动。
需要指定NotificationService使用的端口号,这里是7981。
注意,如果启动中出现错误,可能需要修改JacORB的安装目录下的etc/jacorb.properties文件中的某些设置。

set CLASSPATH=.
set CLASSPATH=%CLASSPATH%;../lib/slf4j-api-1.6.4.jar
set CLASSPATH=%CLASSPATH%;../lib/slf4j-jdk14-1.6.4.jar
set CLASSPATH=%CLASSPATH%;../lib/jacorb.jar
set CLASSPATH=%CLASSPATH%;../lib/jacorb-services.jar
set CLASSPATH=%CLASSPATH%;../lib/antlr-2.7.2.jar
set CLASSPATH=%CLASSPATH%;../lib/picocontainer-1.2.jar

set SYSTEM_PROPS=-Djacorb.home=..
set SYSTEM_PROPS=%SYSTEM_PROPS% -Dorg.omg.CORBA.ORBClass=org.jacorb.orb.ORB
set SYSTEM_PROPS=%SYSTEM_PROPS% -Dorg.omg.CORBA.ORBSingletonClass=org.jacorb.orb.ORBSingleton
java %SYSTEM_PROPS% -cp %CLASSPATH% org.jacorb.notification.ConsoleMain -port 7981 -printCorbaloc


Server代码
1)StructuredPushSupplierImpl.java

package learning.corba.notification.newsbroadcast.server;

import org.omg.CosNotification.EventType;
import org.omg.CosNotifyComm.InvalidEventType;
import org.omg.CosNotifyComm.StructuredPushSupplierPOA;

public class StructuredPushSupplierImpl extends StructuredPushSupplierPOA {

	public void disconnect_structured_push_supplier() {
		System.out.println("disconnect_structured_push_supplier");
	}

	public void subscription_change(EventType[] added, EventType[] removed)
			throws InvalidEventType {
		throw new UnsupportedOperationException();
	}

}


2)NewsBCNotifServer.java

package learning.corba.notification.newsbroadcast.server;

import java.util.Properties;
import java.util.Random;

import org.omg.CORBA.IntHolder;
import org.omg.CORBA.ORB;
import org.omg.CosEventComm.Disconnected;
import org.omg.CosNaming.NamingContextExt;
import org.omg.CosNaming.NamingContextExtHelper;
import org.omg.CosNotification.DefaultPriority;
import org.omg.CosNotification.EventHeader;
import org.omg.CosNotification.EventType;
import org.omg.CosNotification.FixedEventHeader;
import org.omg.CosNotification.Priority;
import org.omg.CosNotification.Property;
import org.omg.CosNotification.StructuredEvent;
import org.omg.CosNotifyChannelAdmin.ClientType;
import org.omg.CosNotifyChannelAdmin.EventChannel;
import org.omg.CosNotifyChannelAdmin.EventChannelFactory;
import org.omg.CosNotifyChannelAdmin.
This specification describes a CORBA-based Notification Service, a service which<br>extends the existing OMG Event Service, adding to it the following new capabilities:<br>• The ability to transmit events in the form of a well-defined data structure, in<br>addition to Anys and Typed-events as supported by the existing Event Service.<br>• The ability for clients to specify exactly which events they are interested in<br>receiving, by attaching filters to each proxy in a channel.<br>• The ability for the event types required by all consumers of a channel to be<br>discovered by suppliers of that channel, so that suppliers can produce events on<br>demand, or avoid transmitting events in which no consumers have interest.<br>• The ability for the event types offered by suppliers to an event channel to be<br>discovered by consumers of that channel so that consumers may subscribe to new<br>event types as they become available.<br>• The ability to configure various quality of service properties on a per-channel, perproxy,<br>or per-event basis.<br>• An optional event type repository which, if present, facilitates the formation of filter<br>constraints by end-users, by making information about the structure of events which<br>will flow through the channel readily available.<br><br><br>The Notification Service defined here attempts to preserve all of the semantics<br>specified for the OMG Event Service, allowing for interoperability between basic<br>Event Service clients and Notification Service clients. To recap, the OMG Event<br>Service supports asynchronous exchange of event messages between clients. The Event<br>Service introduces event channels which broker event messages, event suppliers which<br>supply event messages, and event consumers which consume event messages.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值