{
ServerEndpointMetaData sepMetaData = ep.getAttachment(ServerEndpointMetaData.class);
if (sepMetaData == null)
throw new IllegalStateException("Cannot obtain endpoint meta data");
EventingEpMetaExt ext = (EventingEpMetaExt)sepMetaData.getExtension(EventingConstants.NS_EVENTING);
if (ext != null)
{
// Currently several endpoints may belong to an event source deployment.
// Therefore we have to avoid duplicate registrations
// Actually there should be a 1:n mapping of event source NS to endpoints.
// See also http://jira.jboss.org/jira/browse/JBWS-770
// create pending incomplete event source
EventingEndpointDeployment desc = new EventingEndpointDeployment(ext.getEventSourceNS(), ext.getNotificationSchema(), ext.getNotificationRootElementNS());
desc.setEndpointAddress(sepMetaData.getEndpointAddress());
desc.setPortName(sepMetaData.getPortName());
SubscriptionManagerFactory factory = SubscriptionManagerFactory.getInstance();
SubscriptionManagerMBean manager = factory.getSubscriptionManager();