Package com.betfair.cougar.api

Examples of com.betfair.cougar.api.ExecutionContext


    public void initialiseExecutionContext() {
        final Identity transportIdentity = new EventTransportIdentityImpl(JmsEventTransportImpl.this, transportIdentifier);

        if (executionContext == null) {
            executionContext = new ExecutionContext() {

                @Override
                public GeoLocationDetails getLocation() { return null; }

                @Override
                public IdentityChain getIdentity() {
                    return new IdentityChain() {
                        List<Identity> identities= new ArrayList<Identity>(1) {{ add(transportIdentity);}};

                        @Override
                        public List<Identity> getIdentities() {
                            return identities;
                        }

                        @Override
                        public void addIdentity(Identity identity) {
                            identities.add(identity);
                        }

                        @SuppressWarnings({"unchecked"})
                        @Override
                        public <T extends Identity> List<T> getIdentities(Class<T> clazz) {
                            List<T> filteredIdentityList = new ArrayList<T>();
                            for (Identity identity : identities) {
                                if (clazz.isAssignableFrom(identity.getClass())) {
                                    filteredIdentityList.add((T)identity);
                                }
                            }
                            return filteredIdentityList;
                        }

                        public String toString() {
                            StringBuffer sb = new StringBuffer("Sonic IdentityChain_");
                            for (int i=0; i<identities.size(); i++) {
                                sb.append("Identity:").append(i).append(" ").append(identities.get(i)).append(" ");
                            }
                            return sb.toString();
                        }
                    };
                }

                @Override
                public RequestUUID getRequestUUID() { return null; }

                @Override
                public Date getReceivedTime() { return null; }

                @Override
                public Date getRequestTime() { return null; }

                @Override
                public boolean traceLoggingEnabled() { return false;}

                @Override
                public int getTransportSecurityStrengthFactor() {
                    return 0// todo: where do we get this from??
                }

                @Override
                public boolean isTransportSecure() {
                    return getTransportSecurityStrengthFactor() > 1;
                }
            };
        } else {
            if (executionContext.getIdentity() != null &&
                    executionContext.getIdentity().getIdentities(EventTransportIdentity.class).isEmpty()) {

                final ExecutionContext delegateExecutionContext = executionContext;
                final List<Identity> augmentedIdentityChainList = new ArrayList<Identity>(delegateExecutionContext.getIdentity().getIdentities());
                augmentedIdentityChainList.add(transportIdentity);

                executionContext = new ExecutionContext() {
                    @Override
                    public IdentityChain getIdentity() {
                        IdentityChain ic = new IdentityChain() {
                            @Override
                            public List<Identity> getIdentities() {
                                return augmentedIdentityChainList;
                            }

                            @Override
                            public void addIdentity(Identity identity) {
                                augmentedIdentityChainList.add(identity);
                            }

                            @Override
                            public <T extends Identity> List<T> getIdentities(Class<T> clazz) {
                                List<T> filteredIdentityChain = new ArrayList<T>();
                                for (Identity identity : augmentedIdentityChainList) {
                                    if (clazz.isAssignableFrom(identity.getClass())) {
                                        filteredIdentityChain.add((T)identity);
                                    }
                                }
                                return filteredIdentityChain;
                            }

                            public String toString() {
                                StringBuffer sb = new StringBuffer("Sonic IdentityChain_\n");
                                for (int i=0; i<augmentedIdentityChainList.size(); i++) {
                                    sb.append("Identity:").append(i).append(" ").append(augmentedIdentityChainList.get(i)).append(" ");
                                }
                                return sb.toString();
                            }
                        };
                        return ic;
                    }
                    @Override
                    public RequestUUID getRequestUUID() { return delegateExecutionContext.getRequestUUID(); }
                    @Override
                    public Date getReceivedTime() { return delegateExecutionContext.getReceivedTime(); }
                    @Override
                    public Date getRequestTime() { return delegateExecutionContext.getRequestTime(); }
                    @Override
                    public boolean traceLoggingEnabled() { return delegateExecutionContext.traceLoggingEnabled(); }
                    @Override
                    public GeoLocationDetails getLocation() { return delegateExecutionContext.getLocation(); }
                    @Override
                    public int getTransportSecurityStrengthFactor() { return delegateExecutionContext.getTransportSecurityStrengthFactor(); }
                    @Override
                    public boolean isTransportSecure() { return delegateExecutionContext.isTransportSecure(); }
                };
            }
        }
    }
View Full Code Here


                observer = expiringObserver;
            }
            observer = new ExecutionObserverWrapper(observer, de.recorder, key);

            try {
                ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx);
                de.exec.execute(contextToUse, key, args, observer, this, timeConstraints);
            } catch (CougarException e) {
                observer.onResult(new ExecutionResult(e));
            } catch (Exception e) {
                observer.onResult(new ExecutionResult(
View Full Code Here

                    }
                    // now we have an ExecutionContext that's correctly filled..
                    else {
                        // this has to be an ExecutionContext and not a ExecutionContextWithTokens to ensure that
                        // BaseExecutionVenue doesn't try to re-resolve
                        ExecutionContext context = ExecutionContextFactory.resolveExecutionContext(finalCtx, finalCtx.getIdentity());
                        for (ExecutionCommand exec : resolver.resolveExecutionCommands()) {
                            executeCommand(exec, context);
                        }
                    }
                }
View Full Code Here

                observer = expiringObserver;
            }
            observer = new ExecutionObserverWrapper(observer, de.recorder, key);

            try {
                ExecutionContext contextToUse = resolveIdentitiesIfRequired(ctx);
                de.exec.execute(contextToUse, key, args, observer, this, timeConstraints);
            } catch (CougarException e) {
                observer.onResult(new ExecutionResult(e));
            } catch (Exception e) {
                observer.onResult(new ExecutionResult(
View Full Code Here

                    }
                    // now we have an ExecutionContext that's correctly filled..
                    else {
                        // this has to be an ExecutionContext and not a ExecutionContextWithTokens to ensure that
                        // BaseExecutionVenue doesn't try to re-resolve
                        ExecutionContext context = ExecutionContextFactory.resolveExecutionContext(finalCtx, finalCtx.getIdentity());
                        for (ExecutionCommand exec : resolver.resolveExecutionCommands()) {
                            executeCommand(exec, context);
                        }
                    }
                }
View Full Code Here

            }
        };
    }

    public static ExecutionContext resolveExecutionContext(final ExecutionContextWithTokens tokenContext, final IdentityChain chain) {
        return new ExecutionContext() {
            @Override
            public GeoLocationDetails getLocation() {
                return tokenContext.getLocation();
            }
View Full Code Here

        int keyLength = 0;
        if (request.getScheme().equals("https")) {
            keyLength = SSLRequestUtils.getTransportSecurityStrengthFactor(request, unknownCipherKeyLength);
        }

        ExecutionContext ctx = ExecutionContextFactory.resolveExecutionContext(cmd, null, uuidHeader, deserializer, geoIPLocator, null, keyLength, false, new Date());
        requestLogger.logAccess(cmd, ctx, 0, bytesWritten, null, mediaType, responseCode);
    }
View Full Code Here

      this.makeCall();
    }
   
    public void makeCall(){
      BaselineSyncClient client = wrapper.getClient();
      ExecutionContext ctx = wrapper.getCtx();
     
      if("testSimpleGet".equals(methodToExecute)){
        try{
          SimpleResponse response = client.testSimpleGet(ctx, "foo");
          this.actualResponse = new JSONObject(response.toString());
View Full Code Here

TOP

Related Classes of com.betfair.cougar.api.ExecutionContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.