Skip to content
Permalink
Browse files
Move to Java 5 to follow Axis2, fix spelling errors, and a little cle…
…anup.
  • Loading branch information
Glen Daniels committed Aug 22, 2008
1 parent 86d903e commit 5454d53c4de689464061d699db96416d967aff62
Showing 14 changed files with 71 additions and 74 deletions.
@@ -34,8 +34,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.4</source>
<target>1.4</target>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
@@ -38,17 +38,17 @@ public SavanMessageContext(MessageContext messageContext) {
}

public void setMessageType(int type) {
messageContext.setProperty(SavanConstants.MESSAGE_TYPE, new Integer(type));
messageContext.setProperty(SavanConstants.MESSAGE_TYPE, type);
}

public int getMessageType() {
Integer typeInt = (Integer)messageContext.getProperty(SavanConstants.MESSAGE_TYPE);
if (typeInt == null) {
typeInt = new Integer(SavanConstants.MessageTypes.UNKNOWN);
typeInt = SavanConstants.MessageTypes.UNKNOWN;
messageContext.setProperty(SavanConstants.MESSAGE_TYPE, typeInt);
}

return typeInt.intValue();
return typeInt;
}

public ConfigurationContext getConfigurationContext() {
@@ -33,7 +33,7 @@
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanException;
import org.apache.savan.SavanMessageContext;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.messagereceiver.MessageReceiverDelegator;
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.util.CommonUtil;
@@ -46,7 +46,7 @@
import java.util.Date;


public class AtomMessageReceiverDeligater extends MessageReceiverDeligater {
public class AtomMessageReceiverDelegator extends MessageReceiverDelegator {
private SOAPEnvelope findOrCreateSoapEnvelope(SavanMessageContext subscriptionMessage,
MessageContext outMessage) throws AxisFault {
MessageContext subscriptionMsgCtx = subscriptionMessage.getMessageContext();
@@ -20,7 +20,7 @@
import org.apache.axis2.context.MessageContext;
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanMessageContext;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.messagereceiver.MessageReceiverDelegator;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.subscription.SubscriptionProcessor;
import org.apache.savan.util.UtilFactory;
@@ -62,8 +62,8 @@ public SubscriptionProcessor createSubscriptionProcessor() {
return new AtomSubscriptionProcessor();
}

public MessageReceiverDeligater createMessageReceiverDeligater() {
return new AtomMessageReceiverDeligater();
public MessageReceiverDelegator createMessageReceiverDelegator() {
return new AtomMessageReceiverDelegator();
}

public Subscriber createSubscriber() {
@@ -31,7 +31,7 @@
import org.apache.savan.SavanException;
import org.apache.savan.SavanMessageContext;
import org.apache.savan.eventing.subscribers.EventingSubscriber;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.messagereceiver.MessageReceiverDelegator;
import org.apache.savan.storage.SubscriberStore;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.util.CommonUtil;
@@ -41,7 +41,7 @@
import java.util.Date;


public class EventingMessageReceiverDeligater extends MessageReceiverDeligater {
public class EventingMessageReceiverDelegator extends MessageReceiverDelegator {

public void doProtocolSpecificProcessing(SavanMessageContext inSavanMessage,
MessageContext outMessage) throws SavanException {
@@ -21,7 +21,7 @@
import org.apache.savan.SavanConstants;
import org.apache.savan.SavanMessageContext;
import org.apache.savan.eventing.subscribers.EventingSubscriber;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.messagereceiver.MessageReceiverDelegator;
import org.apache.savan.subscribers.Subscriber;
import org.apache.savan.subscription.SubscriptionProcessor;
import org.apache.savan.util.UtilFactory;
@@ -62,8 +62,8 @@ public SubscriptionProcessor createSubscriptionProcessor() {
return new EventingSubscriptionProcessor();
}

public MessageReceiverDeligater createMessageReceiverDeligater() {
return new EventingMessageReceiverDeligater();
public MessageReceiverDelegator createMessageReceiverDelegator() {
return new EventingMessageReceiverDelegator();
}

public Subscriber createSubscriber() {
@@ -31,7 +31,7 @@
import org.apache.savan.util.UtilFactory;

/** Provide abstract functions that may be done by protocols at the MessageReceiver level. */
public abstract class MessageReceiverDeligater {
public abstract class MessageReceiverDelegator {


public void processMessage(SavanMessageContext smc) throws SavanException {
@@ -56,7 +56,6 @@ public void processMessage(SavanMessageContext smc) throws SavanException {
Parameter parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
if (parameter == null) {
setSubscriberStore(smc);
parameter = axisService.getParameter(SavanConstants.SUBSCRIBER_STORE);
}

UtilFactory utilFactory = smc.getProtocol().getUtilFactory();
@@ -66,14 +65,22 @@ public void processMessage(SavanMessageContext smc) throws SavanException {

SubscriptionProcessor processor = utilFactory.createSubscriptionProcessor();
processor.init(smc);
if (messageType == SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE) {
processor.subscribe(smc);
} else if (messageType == SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE) {
processor.unsubscribe(smc);
} else if (messageType == SavanConstants.MessageTypes.RENEW_MESSAGE) {
processor.renewSubscription(smc);
} else if (messageType == SavanConstants.MessageTypes.PUBLISH) {
processor.publish(smc);
switch (messageType) {
case SavanConstants.MessageTypes.SUBSCRIPTION_MESSAGE:
processor.subscribe(smc);
break;
case SavanConstants.MessageTypes.UNSUBSCRIPTION_MESSAGE:
processor.unsubscribe(smc);
break;
case SavanConstants.MessageTypes.RENEW_MESSAGE:
processor.renewSubscription(smc);
break;
case SavanConstants.MessageTypes.PUBLISH:
processor.publish(smc);
break;
case SavanConstants.MessageTypes.GET_STATUS_MESSAGE:
processor.getStatus(smc);
break;
}
}

@@ -45,10 +45,10 @@ public void invokeBusinessLogic(MessageContext inMessage, MessageContext outMess
savanInMessage.setProtocol(protocol);

UtilFactory utilFactory = protocol.getUtilFactory();
MessageReceiverDeligater deligator = utilFactory.createMessageReceiverDeligater();
MessageReceiverDelegator delegator = utilFactory.createMessageReceiverDelegator();

deligator.processMessage(savanInMessage);
deligator.doProtocolSpecificProcessing(savanInMessage, outMessage);
delegator.processMessage(savanInMessage);
delegator.doProtocolSpecificProcessing(savanInMessage, outMessage);

}

@@ -51,7 +51,7 @@ public void renewSubscription(SavanMessageContext renewMessage) throws SavanExce
throw new SavanException("AbstractSubscriber store not found");

ExpirationBean bean = getExpirationBean(renewMessage);
Subscriber subscriber = (Subscriber)store.retrieve(bean.getSubscriberID());
Subscriber subscriber = store.retrieve(bean.getSubscriberID());
if (subscriber == null) {
throw new SavanException("Given subscriber is not present");
}
@@ -61,9 +61,6 @@ public void renewSubscription(SavanMessageContext renewMessage) throws SavanExce

public void subscribe(SavanMessageContext subscriptionMessage) throws SavanException {
SubscriberStore store = subscriptionMessage.getSubscriberStore();
if (store == null)
throw new SavanException("AbstractSubscriber store not found");

if (store == null)
throw new SavanException("Sabscriber store not found");

@@ -76,10 +73,13 @@ public void endSubscription(String subscriberID, String reason, ServiceContext s

SubscriberStore store = CommonUtil.getSubscriberStore(serviceContext.getAxisService());
if (store == null) {
//TODO do something
throw new SavanException("SubscriberStore not found");
}

Subscriber subscriber = store.retrieve(subscriberID);
if (subscriber == null) {
throw new SavanException("No such subscriber '" + subscriberID + "'");
}
// doProtocolSpecificEndSubscription(subscriber,reason,serviceContext.getConfigurationContext());

store.delete(subscriberID);
@@ -94,6 +94,8 @@ public void publish(SavanMessageContext publishMessage) throws SavanException {
serviceContext.getAxisService(), null);
}

public void getStatus(SavanMessageContext smc) {
}

public abstract void pauseSubscription(SavanMessageContext pauseSubscriptionMessage)
throws SavanException;
@@ -108,6 +110,4 @@ public abstract ExpirationBean getExpirationBean(SavanMessageContext renewMessag
throws SavanException;

public abstract String getSubscriberID(SavanMessageContext smc) throws SavanException;


}
@@ -18,7 +18,7 @@
package org.apache.savan.util;

import org.apache.savan.SavanMessageContext;
import org.apache.savan.messagereceiver.MessageReceiverDeligater;
import org.apache.savan.messagereceiver.MessageReceiverDelegator;
import org.apache.savan.subscription.SubscriptionProcessor;

/**
@@ -31,6 +31,6 @@ public interface UtilFactory {

public abstract SubscriptionProcessor createSubscriptionProcessor();

public abstract MessageReceiverDeligater createMessageReceiverDeligater();
public abstract MessageReceiverDelegator createMessageReceiverDelegator();

}
@@ -52,8 +52,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.4</source>
<target>1.4</target>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>

@@ -16,10 +16,6 @@

package sample.eventing;

import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
import org.apache.axis2.AxisFault;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
@@ -30,14 +26,14 @@
import org.apache.savan.eventing.client.EventingClientBean;
import org.apache.savan.eventing.client.SubscriptionStatus;

import javax.xml.namespace.QName;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;

public class Client {

boolean done = false;

BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));

private final int MIN_OPTION = 1;
@@ -46,16 +42,14 @@ public class Client {
private final String SUBSCRIBER_1_ID = "subscriber1";
private final String SUBSCRIBER_2_ID = "subscriber2";

private ServiceClient serviceClient = null;
private Options options = null;
private EventingClient eventingClient = null;

private String toAddressPart = "/axis2/services/PublisherService";
private String listener1AddressPart = "/axis2/services/ListenerService1";
private String listener2AddressPart = "/axis2/services/ListenerService2";

private final String applicationNamespaceName = "http://tempuri.org/";
private final String dummyMethod = "dummyMethod";
// private final String applicationNamespaceName = "http://tempuri.org/";
// private final String dummyMethod = "dummyMethod";

private static String repo = null;
private static int port = 8080;
@@ -67,8 +61,8 @@ public class Client {

public static void main(String[] args) throws Exception {

for (int i = 0; i < args.length; i++) {
if (helpParam.equalsIgnoreCase(args[i])) {
for (String arg : args) {
if (helpParam.equalsIgnoreCase(arg)) {
displayHelp();
System.exit(0);
}
@@ -140,14 +134,13 @@ public void run() throws Exception {

//TODO publish

System.out.println("Press enter to initialize the publisher service.");
reader.readLine();

options.setAction("uuid:DummyMethodAction");
serviceClient.fireAndForget(getDummyMethodRequestElement());

while (true) {
// System.out.println("Press enter to initialize the publisher service.");
// reader.readLine();
//
// options.setAction("uuid:DummyMethodAction");
// serviceClient.fireAndForget(getDummyMethodRequestElement());

while (!done) {
validOptionSelected = false;
selectedOption = -1;
while (!validOptionSelected) {
@@ -187,24 +180,21 @@ private int getIntInput() throws IOException {
}

private void initClient() throws AxisFault {

String CLIENT_REPO = null;
String AXIS2_XML = null;

if (repo != null) {
CLIENT_REPO = repo;
AXIS2_XML = repo + File.separator + "axis2.xml";
} else {
// throw new AxisFault ("Please specify the client repository as a program argument.Use '-h' for help.");
}

ConfigurationContext configContext = ConfigurationContextFactory
.createConfigurationContextFromFileSystem(CLIENT_REPO, null);
serviceClient = new ServiceClient(configContext, null); //TODO give a repo
ServiceClient serviceClient = new ServiceClient(configContext, null);

options = new Options();
Options options = new Options();
serviceClient.setOptions(options);
serviceClient.engageModule(new QName("addressing"));
serviceClient.engageModule("addressing");

eventingClient = new EventingClient(serviceClient);

@@ -242,7 +232,7 @@ private void performAction(int action) throws Exception {
doGetStatus(SUBSCRIBER_2_ID);
break;
case 9:
System.exit(0);
done = true;
break;
default:
break;
@@ -283,10 +273,10 @@ private void doGetStatus(String ID) throws Exception {
System.out.println("Status of the subscriber '" + ID + "' is" + statusValue);
}

private OMElement getDummyMethodRequestElement() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
return fac.createOMElement(dummyMethod, namespace);
}
// private OMElement getDummyMethodRequestElement() {
// OMFactory fac = OMAbstractFactory.getOMFactory();
// OMNamespace namespace = fac.createOMNamespace(applicationNamespaceName, "ns1");
// return fac.createOMElement(dummyMethod, namespace);
// }

}
@@ -35,8 +35,8 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.4</source>
<target>1.4</target>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<!--

0 comments on commit 5454d53

Please sign in to comment.