[personal profile] kds

import java.util.Enumeration;
import java.util.concurrent.TimeUnit;

import org.jdiameter.api.ApplicationId;
import org.jdiameter.api.Configuration;
import org.jdiameter.api.InternalException;
import org.jdiameter.api.Message;
import org.jdiameter.api.Stack;
import org.jdiameter.api.StackManager;
import org.jdiameter.api.cca.ClientCCASession;
import org.jdiameter.api.validation.AvpRepresentation;
import org.jdiameter.client.api.ISessionFactory;
import org.jdiameter.client.impl.StackImpl;
import org.jdiameter.client.impl.helpers.XMLConfiguration;
import org.jdiameter.common.impl.app.cca.CCASessionFactoryImpl;
import org.jdiameter.common.impl.app.cca.JCreditControlRequestImpl;
import org.jdiameter.common.impl.validation.DictionaryImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* date: 21.04.11
* time: 13:31
* makedoc
*
* @version $Id$
*/
public class StackController {
private static Logger LOG = LoggerFactory.getLogger(StackController.class);

public static void main(String[] args) {
TicSessionID ticSessionID = new TicSessionID(SessionIDGenerator.getNewSessionID());
final String DEBUG_STR = ticSessionID + ":main: ";
LOG.debug("{} start", DEBUG_STR);

Stack s = new StackImpl();
try {
StackManager.registerStack(s);
} catch (InternalException e) {
LOG.error(DEBUG_STR, e);
}


Enumeration<Stack> stacks = StackManager.getStacks();
LOG.info("{} stacks {}", DEBUG_STR, stacks);
while (stacks.hasMoreElements()) {
Stack stack = stacks.nextElement();
LOG.info("{} stack {}", DEBUG_STR, stack);
}

try {
LOG.info("{} stack is active {}", DEBUG_STR, s.isActive());

Configuration c = new XMLConfiguration(StackController.class.getClassLoader().getResourceAsStream("diameter-client.xml"));
ISessionFactory sessionFactory = (ISessionFactory) s.init(c);
s.start();

LOG.info("{} stack is active {}", DEBUG_STR, s.isActive());

DictionaryImpl dictionary = (DictionaryImpl) s.getDictionary();
dictionary.configure(StackController.class.getClassLoader().getResourceAsStream("dictionary.xml"));
dictionary.setEnabled(true);
LOG.info("{} configured {}", DEBUG_STR, dictionary.isConfigured());
LOG.info("{} enabled {}", DEBUG_STR, dictionary.isEnabled());

sessionFactory.registerAppFacory(ClientCCASession.class, new CCASessionFactoryImpl(sessionFactory));

ApplicationId appId = ApplicationId.createByAccAppId(4);
ClientCCASession session = sessionFactory.getNewAppSession(SessionIDGenerator.getNewSessionID(), appId, ClientCCASession.class);
LOG.info("{} session {}", DEBUG_STR, session);
LOG.info("{} session class {}", DEBUG_STR, session.getClass());

ApplicationId sessionAppId = session.getSessionAppId();
LOG.info("{} application id {}", DEBUG_STR, sessionAppId);

JCreditControlRequestImpl event = new JCreditControlRequestImpl(session, "jDiameter", "127.0.0.1");

Message message;
// message = session.getSessions().get(0).createRequest(272, appId, "jDiameter");

AvpRepresentation avpr = CcaDictionary.CCRequestType.avp(dictionary);
message = event.getMessage();

message.getAvps().addAvp(avpr.getCode(), 1, avpr.getVendorId(), avpr.isMandatory(), avpr.isProtected());
LOG.info("{} message {} {} {}", new Object[]{DEBUG_STR, message,message,message});
session.sendCreditControlRequest(event);

s.stop(10, TimeUnit.MILLISECONDS);
} catch (Exception e) {
LOG.error(DEBUG_STR, e);
}

LOG.debug("{} stop", DEBUG_STR);
}
}
From:
Anonymous( )Anonymous This account has disabled anonymous posting.
OpenID( )OpenID You can comment on this post while signed in with an account from many other sites, once you have confirmed your email address. Sign in using OpenID.
User
Account name:
Password:
If you don't have an account you can create one now.
Subject:
HTML doesn't work in the subject.

Message:

 
Notice: This account is set to log the IP addresses of everyone who comments.
Links will be displayed as unclickable URLs to help prevent spam.

Profile

kds

December 2012

S M T W T F S
      1
2345678
9101112131415
1617181920 2122
23242526272829
3031     

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Jul. 23rd, 2017 06:32 am
Powered by Dreamwidth Studios