Revision: 22803
Author: [email protected]
Date: Fri Aug 17 05:19:39 2012
Log: CAP RA Thomazs's patch merging
http://code.google.com/p/mobicents/source/detail?r=22803
Added:
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPRAMarshaler.java
Modified:
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPDialogActivityHandle.java
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPResourceAdaptor.java
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/wrappers/CAPProviderWrapper.java
=======================================
--- /dev/null
+++
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPRAMarshaler.java
Fri Aug 17 05:19:39 2012
@@ -0,0 +1,122 @@
+/*
+ * TeleStax, Open Source Cloud Communications Copyright 2012.
+ * and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.mobicents.slee.resource.cap;
+
+import java.io.DataInput;
+import java.io.DataOutput;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+
+import javax.slee.resource.ActivityHandle;
+import javax.slee.resource.FireableEventType;
+import javax.slee.resource.Marshaler;
+
+/**
+ * @author Tomasz Domin [email protected]
+ */
+public class CAPRAMarshaler implements Marshaler {
+
+ // Events
-----------------------------------------------------------------
+
+ public int getEstimatedEventSize(FireableEventType eventType, Object
event) {
+ // TODO: return an estimation of the size (in bytes) of the
marshaled
+ // form of an Event object generated by the Resource
Adaptor. It
+ // can be used by the SLEE to help size appropriately any
+ // internal buffers used to store the marshaled form of
an Event.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public ByteBuffer getEventBuffer(FireableEventType eventType, Object
event) {
+ // TODO: return a ByteBuffer containing an already marshaled
form of
+ // the Event object specified by the event argument. The
+ // eventType argument specifies the event type of the
Event. The
+ // exact purpose of this method is to give the Resource
Adaptor
+ // an opportunity to provide the SLEE with a view buffer
onto an
+ // existing buffer that already contains the marshaled
form of
+ // the Event object.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void releaseEventBuffer(FireableEventType eventType, Object event,
ByteBuffer buffer) {
+ // TODO: release any resources associated with the specified
ByteBuffer
+ // when this method is invoked as the SLEE will no longer
use the
+ // buffer.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void marshalEvent(FireableEventType eventType, Object event,
DataOutput out) throws IOException {
+ // TODO: return the marshaled form of an Event object. The
Resource
+ // Adaptor should write a serialized form of the Event
object
+ // specified by the event argument using the DataOutput
object
+ // specified by the out argument. The eventType argument
+ // identifies the event type of the Event object.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public Object unmarshalEvent(FireableEventType eventType, DataInput in)
throws IOException {
+ // TODO: read the marshaled form of the Event object from the
DataInput
+ // object specified by the in argument and reconstruct
the Event
+ // object. The eventType argument identifies the event
type of
+ // the Event object that is marshaled and provides access
to the
+ // class name of the event type and a class loader that
can be
+ // used to load the event class if required.
+
+ throw new UnsupportedOperationException();
+ }
+
+ // Activity Handles
-------------------------------------------------------
+
+ public int getEstimatedHandleSize(ActivityHandle handle) {
+ // TODO: return an estimation of the size (in bytes) of the
marshaled
+ // form of an Activity Handle object generated by the
Resource
+ // Adaptor. It can be used by the SLEE to help size
appropriately
+ // any internal buffers used to store the marshaled form
of an
+ // Activity Handle.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public void marshalHandle(ActivityHandle handle, DataOutput out) throws
IOException {
+ // TODO: return the marshaled form of an ActivityHandle object.
The
+ // Resource Adaptor should write a serialized form of the
+ // ActivityHandle object specified by the handle argument
using
+ // the DataOutput object specified by the out argument.
+
+ throw new UnsupportedOperationException();
+ }
+
+ public ActivityHandle unmarshalHandle(DataInput in) throws IOException {
+ // TODO: return an unmarshaled ActivityHandle object previously
+ // marshaled by the Resource Adaptor. The Resource
Adaptor should
+ // read the marshaled form of the Activity Handle from the
+ // DataInput object specified by the in argument and
reconstruct
+ // the ActivityHandle object.
+
+ throw new UnsupportedOperationException();
+ }
+
+}
=======================================
---
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPDialogActivityHandle.java
Tue Aug 7 04:00:34 2012
+++
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPDialogActivityHandle.java
Fri Aug 17 05:19:39 2012
@@ -34,6 +34,7 @@
*/
public class CAPDialogActivityHandle implements Serializable,
ActivityHandle {
+ private static final long serialVersionUID = 1L;
private long dialogId;
private transient CAPDialogWrapper activity;
=======================================
---
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPResourceAdaptor.java
Tue Aug 7 04:00:34 2012
+++
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/CAPResourceAdaptor.java
Fri Aug 17 05:19:39 2012
@@ -48,6 +48,7 @@
import org.mobicents.protocols.ss7.cap.api.CAPDialog;
import org.mobicents.protocols.ss7.cap.api.CAPDialogListener;
+import org.mobicents.protocols.ss7.cap.api.CAPException;
import org.mobicents.protocols.ss7.cap.api.CAPMessage;
import org.mobicents.protocols.ss7.cap.api.CAPProvider;
import org.mobicents.protocols.ss7.cap.api.dialog.CAPComponentErrorReason;
@@ -139,6 +140,7 @@
* @author amit bhayani
* @author baranowb
* @author sergey vetyutnev
+ * @author Tomasz Domin [email protected]
*
*/
public class CAPResourceAdaptor implements ResourceAdaptor,
CAPDialogListener, CAPServiceCircuitSwitchedCallListener,
CAPServiceGprsListener,
@@ -158,6 +160,7 @@
protected CAPProvider realProvider = null; // so we dont have to "get"
private Tracer tracer;
private transient SleeEndpoint sleeEndpoint = null;
+ private Marshaler marshaler = new CAPRAMarshaler();
private ResourceAdaptorContext resourceAdaptorContext;
@@ -201,27 +204,34 @@
}
- public void administrativeRemove(ActivityHandle arg0) {
- // TODO Auto-generated method stub
-
+ public void administrativeRemove(ActivityHandle handle) {
+ if (tracer.isFineEnabled())
+ tracer.fine("administrativeRemove:" + handle);
}
- public void eventProcessingFailed(ActivityHandle arg0, FireableEventType
arg1, Object arg2, Address arg3,
- ReceivableService arg4, int arg5, FailureReason arg6) {
- // TODO Auto-generated method stub
-
+ public void eventProcessingFailed(ActivityHandle handle,
FireableEventType eventType, Object event,
+ Address address, ReceivableService service, int flags, FailureReason
reason) {
+ if (tracer.isFineEnabled())
+ tracer.fine("eventProcessingFailed:" + eventType + ":"
+ handle);
+ // used to inform the resource adaptor object that the
specified Event
+ // could not be processed successfully by the SLEE.
}
- public void eventProcessingSuccessful(ActivityHandle arg0,
FireableEventType arg1, Object arg2, Address arg3,
- ReceivableService arg4, int arg5) {
- // TODO Auto-generated method stub
-
+ public void eventProcessingSuccessful(ActivityHandle handle,
FireableEventType eventType, Object event,
+ Address address, ReceivableService service, int flags) {
+ if (tracer.isFineEnabled())
+ tracer.fine("eventProcessingSuccessful:" + eventType +
":" + handle);
+ // used to inform the resource adaptor object that the
specified Event
+ // was processed successfully by the SLEE.
}
- public void eventUnreferenced(ActivityHandle arg0, FireableEventType
arg1, Object arg2, Address arg3,
- ReceivableService arg4, int arg5) {
- // TODO Auto-generated method stub
-
+ public void eventUnreferenced(ActivityHandle handle, FireableEventType
eventType, Object event, Address address,
+ ReceivableService service, int flags) {
+ if (tracer.isFineEnabled())
+ tracer.fine("eventUnreferenced:" + eventType + ":" +
handle);
+ // used to inform the Resource Adaptor that the SLEE no longer
+ // references an Event object which was previously fired by the
+ // resource adaptor object.
}
public Object getActivity(ActivityHandle handle) {
@@ -240,11 +250,10 @@
}
public Marshaler getMarshaler() {
- // TODO Auto-generated method stub
- return null;
+ return marshaler; // return null if no marshaler is to be used.
}
- public Object getResourceAdaptorInterface(String arg0) {
+ public Object getResourceAdaptorInterface(String className) {
return this.capProvider;
}
@@ -298,6 +307,12 @@
}
public void raInactive() {
+ if (tracer.isFineEnabled())
+ tracer.fine("raInactive");
+ if (tracer.isFineEnabled()) {
+ tracer.fine("CAP Resource Adaptor - inactivating");
+ }
+
this.realProvider.getCAPServiceCircuitSwitchedCall().deactivate();
this.realProvider.getCAPServiceGprs().deactivate();
this.realProvider.getCAPServiceSms().deactivate();
@@ -307,15 +322,36 @@
this.realProvider.getCAPServiceSms().removeCAPServiceListener(this);
this.realProvider.removeCAPDialogListener(this);
+
+ if (tracer.isInfoEnabled()) {
+ tracer.info("CAP Resource Adaptor entity inactive.");
+ }
}
public void raStopping() {
- // TODO Auto-generated method stub
+ if (tracer.isFineEnabled()) {
+ tracer.fine("raStopping");
+ tracer.fine("Ending all activities");
+ }
+// for (CAPDialog a : activities.values()) {
+// endActivity(a);
+// }
+
+ if (tracer.isFineEnabled()) {
+ tracer.fine("CAP Resource Adaptor entity stopping.");
+ }
}
public void raUnconfigure() {
+ if (tracer.isFineEnabled())
+ tracer.fine("raUnconfigure");
+
this.capJndi = null;
+
+ if (tracer.isFineEnabled()) {
+ tracer.fine("CAP Resource Adaptor unconfigured.");
+ }
}
public void raVerifyConfiguration(ConfigProperties properties) throws
InvalidConfigurationException {
@@ -333,6 +369,10 @@
} catch (Exception e) {
throw new InvalidConfigurationException("Failed to test configuration
options!", e);
}
+
+ if (tracer.isInfoEnabled()) {
+ tracer.info("CAP Resource Adaptor configuration
verified.");
+ }
}
public void serviceActive(ReceivableService receivableService) {
@@ -350,6 +390,7 @@
public void setResourceAdaptorContext(ResourceAdaptorContext raContext)
{
this.resourceAdaptorContext = raContext;
this.tracer =
resourceAdaptorContext.getTracer(CAPResourceAdaptor.class.getSimpleName());
+ this.sleeEndpoint = raContext.getSleeEndpoint();
this.eventIdCache = new EventIDCache(this.tracer);
}
@@ -369,7 +410,30 @@
public void startSuspendedActivity(CAPDialogWrapper capDialogWrapper)
throws ActivityAlreadyExistsException,
NullPointerException, IllegalStateException, SLEEException,
StartActivityException {
this.sleeEndpoint.startActivitySuspended(capDialogWrapper.getActivityHandle(),
capDialogWrapper,
- ActivityFlags.REQUEST_ENDED_CALLBACK);
+ ACTIVITY_FLAGS);
+ }
+
+ // sending capDialog.abort() and then endActivity()
+ private void endActivity(CAPDialogWrapper capDialog) {
+ if (tracer.isFineEnabled())
+ tracer.fine("endActivity:" + capDialog);
+
+ CAPDialogActivityHandle capDialogActHndl =
capDialog.getActivityHandle();
+ if (capDialogActHndl == null) {
+ if (this.tracer.isWarningEnabled()) {
+ this.tracer.warning("Activity ended but no CAPDialogActivityHandle
found for Dialog ID, ignoring "
+ + capDialog.getDialogId());
+ }
+ } else {
+ try {
+
capDialog.abort(CAPUserAbortReason.no_reason_given);
+ } catch (CAPException e) {
+ tracer.warning("Cannot abort dialog ", e);
+ }
+ this.sleeEndpoint.endActivity(capDialogActHndl);
+ if (tracer.isFineEnabled())
+ this.tracer.fine("Activity marked to be ended:" +
capDialog.getDialogId());
+ }
}
/**
=======================================
---
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/wrappers/CAPProviderWrapper.java
Tue Aug 7 04:00:34 2012
+++
/trunk/servers/jain-slee/resources/cap/ra/src/main/java/org/mobicents/slee/resource/cap/wrappers/CAPProviderWrapper.java
Fri Aug 17 05:19:39 2012
@@ -30,6 +30,9 @@
import
org.mobicents.protocols.ss7.cap.api.service.circuitSwitchedCall.CAPServiceCircuitSwitchedCall;
import org.mobicents.protocols.ss7.cap.api.service.gprs.CAPServiceGprs;
import org.mobicents.protocols.ss7.cap.api.service.sms.CAPServiceSms;
+import org.mobicents.protocols.ss7.inap.api.INAPParameterFactory;
+import org.mobicents.protocols.ss7.isup.ISUPParameterFactory;
+import org.mobicents.protocols.ss7.map.api.MAPParameterFactory;
import org.mobicents.slee.resource.cap.CAPDialogActivityHandle;
import org.mobicents.slee.resource.cap.CAPResourceAdaptor;
import
org.mobicents.slee.resource.cap.service.circuitSwitchedCall.wrappers.CAPServiceCircuitSwitchedCallWrapper;
@@ -78,6 +81,27 @@
}
return this.wrappedProvider.getCAPParameterFactory();
}
+
+ public INAPParameterFactory getINAPParameterFactory() {
+ if (this.wrappedProvider == null) {
+ throw new IllegalStateException("RA is has not been
activated.");
+ }
+ return this.wrappedProvider.getINAPParameterFactory();
+ }
+
+ public ISUPParameterFactory getISUPParameterFactory() {
+ if (this.wrappedProvider == null) {
+ throw new IllegalStateException("RA is has not been
activated.");
+ }
+ return this.wrappedProvider.getISUPParameterFactory();
+ }
+
+ public MAPParameterFactory getMAPParameterFactory() {
+ if (this.wrappedProvider == null) {
+ throw new IllegalStateException("RA is has not been
activated.");
+ }
+ return this.wrappedProvider.getMAPParameterFactory();
+ }
public CAPErrorMessageFactory getCAPErrorMessageFactory() {
if (this.wrappedProvider == null) {
@@ -90,6 +114,9 @@
if (this.wrappedProvider == null) {
throw new IllegalStateException("RA is has not been
activated.");
}
+
+ // TODO: .................... caching ?
+
CAPDialogActivityHandle ah = new
CAPDialogActivityHandle(dialogId);
return (CAPDialog) this.ra.getActivity(ah);
}