ServiceDefinitionUtil { protected static MEPDefinition processServiceInvoked(java.util.Map<String,ServiceDefinition> sdefs, ActivityUnit actUnit, RequestReceived rqr, ResponseSent rps) { MEPDefinition ret=null; if (rqr.getServiceType() == null) { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Can't process service invocation with missing service type and interface '" +rqr.getInterface()+"'"); } return null; } if (rqr.getInterface() == null) { if (LOG.isLoggable(Level.FINEST)) { LOG.finest("Can't process service invocation for service type '" +rqr.getServiceType()+"' due to missing interface"); } return null; } ServiceDefinition sd=sdefs.get(rqr.getServiceType()); if (sd == null) { sd = new ServiceDefinition(); sd.setServiceType(rqr.getServiceType()); sd.setInternal(rqr.getInternal() || rps.getInternal()); sdefs.put(rqr.getServiceType(), sd); } InterfaceDefinition id=sd.getInterface(rqr.getInterface()); if (id == null) { id = new InterfaceDefinition(); id.setInterface(rqr.getInterface()); sd.getInterfaces().add(id); } OperationDefinition op=id.getOperation(rqr.getOperation()); if (op == null) { op = new OperationDefinition(); op.setName(rqr.getOperation()); id.getOperations().add(op); } InvocationMetric metrics=null; if (rps.getFault() == null || rps.getFault().trim().length() == 0) { RequestResponseDefinition nrd=op.getRequestResponse(); if (nrd == null) { nrd = new RequestResponseDefinition(); op.setRequestResponse(nrd); nrd.setRequestId(ActivityTypeId.createId(rqr)); nrd.setResponseId(ActivityTypeId.createId(rps)); } metrics = nrd.getMetrics(); ret = nrd; } else { RequestFaultDefinition frd=op.getRequestFault(rps.getFault()); if (frd == null) { frd = new RequestFaultDefinition(); frd.setFault(rps.getFault()); frd.setRequestId(ActivityTypeId.createId(rqr)); frd.setResponseId(ActivityTypeId.createId(rps)); op.getRequestFaults().add(frd); } metrics = frd.getMetrics(); metrics.setFaults(metrics.getFaults()+1); ret = frd; } if (ret != null) { ret.getProperties().putAll(rqr.getProperties()); ret.getProperties().putAll(rps.getProperties()); if (!ret.getProperties().containsKey(PRINCIPAL)) { if (rqr.getPrincipal() != null) { ret.getProperties().put(PRINCIPAL, rqr.getPrincipal()); } else if (rps.getPrincipal() != null) { ret.getProperties().put(PRINCIPAL, rps.getPrincipal()); } } if (actUnit != null && actUnit.getOrigin() != null) { ret.getProperties().put("host", actUnit.getOrigin().getHost()); ret.getProperties().put("node", actUnit.getOrigin().getNode()); } } long duration=rps.getTimestamp()-rqr.getTimestamp(); metrics.setAverage(((metrics.getAverage() * metrics.getCount())+duration) / (metrics.getCount()+1)); if (metrics.getMin() == 0 || duration < metrics.getMin()) { metrics.setMin(duration); } if (duration > metrics.getMax()) { metrics.setMax(duration); } metrics.setCount(metrics.getCount()+1); sd.getContext().addAll(rqr.getContext()); java.util.Iterator<Context> iter=rps.getContext().iterator(); while (iter.hasNext()) { Context c=iter.next(); if (!sd.getContext().contains(c)) { sd.getContext().add(c); } } return (ret); } private  ServiceDefinitionUtil(); static byte[] serializeServiceDefinition(ServiceDefinition sdef); static ServiceDefinition deserializeServiceDefinition(byte[] sdef); static java.util.Collection<ServiceDefinition> derive(ActivityUnit actUnit); static java.util.Map<String,ServiceDefinition> mergeSnapshots(
                    java.util.List<java.util.Map<String,ServiceDefinition>> snapshots); static java.util.Map<String,ServiceDefinition> mergeSnapshots(
                    java.util.List<java.util.Map<String,ServiceDefinition>> snapshots,
                    boolean retainContexts);  }
@Test public void testSeviceDefinitionInterfaceNull() { RequestReceived rqr=new RequestReceived(); rqr.setServiceType(SERVICE_TYPE_1); try { ServiceDefinitionUtil.processServiceInvoked(new java.util.HashMap<String,ServiceDefinition>(), null, rqr, null); } catch (Exception e) { fail("Failed to process request received"); } }