Package org.drools.marshalling

Examples of org.drools.marshalling.ObjectMarshallingStrategy


            for (int i = 0; i < nbVariables; i++) {
                String name = stream.readUTF();
                try {
                    int index = stream.readInt();
                    ObjectMarshallingStrategy strategy = null;
                    // Old way of retrieving strategy objects
                    if (index >= 0) {
                        strategy = context.resolverStrategyFactory.getStrategy( index );
                        if (strategy == null) {
                            throw new IllegalStateException( "No strategy of with index " + index + " available." );
                        }
                    }
                    // New way
                    else if (index == -2) {
                        String strategyClassName = stream.readUTF();
                        strategy = context.resolverStrategyFactory.getStrategyObject( strategyClassName );
                        if (strategy == null) {
                            throw new IllegalStateException( "No strategy of type " + strategyClassName + " available." );
                        }
                    }

                    Object value = strategy.read( stream );
                    workItem.setParameter( name,
                                           value );
                } catch (ClassNotFoundException e) {
                    throw new IllegalArgumentException(
                                                        "Could not reload variable " + name );
View Full Code Here


    }
   
    private static void loadStrategiesIndex(MarshallerReaderContext context,
                                            ProtobufMessages.Header _header) throws IOException, ClassNotFoundException {
        for ( ProtobufMessages.Header.StrategyIndex _entry : _header.getStrategyList() ) {
            ObjectMarshallingStrategy strategyObject = context.resolverStrategyFactory.getStrategyObject( _entry.getName() );
            if ( strategyObject == null ) {
                throw new IllegalStateException( "No strategy of type " + _entry.getName() + " available." );
            }
            context.usedStrategies.put( _entry.getId(), strategyObject );
            Context ctx = strategyObject.createContext();
            context.strategyContexts.put( strategyObject, ctx );
            if( _entry.hasData() && ctx != null ) {
    ClassLoader classLoader = null;
                if (context.classLoader != null ){
                    classLoader = context.classLoader;
View Full Code Here

    }
        

    private Marshaller createSerializableMarshaller(KnowledgeBase knowledgeBase) {
        ObjectMarshallingStrategyAcceptor acceptor = MarshallerFactory.newClassFilterAcceptor( new String[]{ "*.*" } );
        ObjectMarshallingStrategy strategy = MarshallerFactory.newSerializeMarshallingStrategy( acceptor );
        Marshaller marshaller = MarshallerFactory.newMarshaller( knowledgeBase,
                                                                 new ObjectMarshallingStrategy[]{ strategy } );
        return marshaller;
    }
View Full Code Here

        }

        int strategyIndex = context.stream.readInt();
        Object object;
        if ( strategyIndex >= 0 ) {
            ObjectMarshallingStrategy strategy = context.resolverStrategyFactory.getStrategy( strategyIndex );
            object = strategy.read( context.stream );
        } else {
            object = null;
        }
       
        WorkingMemoryEntryPoint entryPoint = null;
View Full Code Here

               
                for (int i = 0; i < nbVariables; i++) {
                    String name = stream.readUTF();
                    try {
                        int index = stream.readInt();
                        ObjectMarshallingStrategy strategy = context.resolverStrategyFactory.getStrategy(index);
                       
                        Object value = strategy.read(stream);
                        workItem.setParameter(name, value);
                    } catch (ClassNotFoundException e) {
                        throw new IllegalArgumentException(
                                "Could not reload variable " + name);
                    }
View Full Code Here

        droolsOut.close();
    }

    private Marshaller createMarshaller( KnowledgeBase kbase ) {
        ObjectMarshallingStrategyAcceptor acceptor = MarshallerFactory.newClassFilterAcceptor( new String[]{ "*.*" } );
        ObjectMarshallingStrategy strategy = MarshallerFactory.newSerializeMarshallingStrategy( acceptor );
        return MarshallerFactory.newMarshaller( kbase, new ObjectMarshallingStrategy[] { strategy } );
    }
View Full Code Here

    }
   
    private static ObjectMarshallingStrategy [] addProcessInstanceResolverStrategyIfAvailable(
            ObjectMarshallingStrategy [] strategies ) {
    
        ObjectMarshallingStrategy processInstanceResolverStrategyObject = null;
        try {
            Class<?> strategyClass = Class.forName(PROCESS_INSTANCE_RESOLVER_STRATEGY);
            Constructor<?> constructor = strategyClass.getConstructors()[0];
           
            processInstanceResolverStrategyObject = (ObjectMarshallingStrategy) constructor.newInstance(new Object [0]);
View Full Code Here

            Object object = parameters.get( key );
            if ( object != null ) {
                stream.writeUTF( key );
                int index = context.objectMarshallingStrategyStore.getStrategy( object );
                stream.writeInt( index );
                ObjectMarshallingStrategy strategy = context.objectMarshallingStrategyStore.getStrategy( index );
                if ( strategy.accept( object ) ) {
                    strategy.write( stream,
                            object );
                }
            }

        }
View Full Code Here

        Object object = handle.getObject();

        if ( object != null ) {
            int index = objectMarshallingStrategyStore.getStrategy( object );

            ObjectMarshallingStrategy strategy = objectMarshallingStrategyStore.getStrategy( index );

            stream.writeInt( index );

            strategy.write( stream,
                    object );
        } else {
            stream.writeInt( -1 );
        }
View Full Code Here

    // New marshalling algorithm methods
    public ObjectMarshallingStrategy getStrategyObject(String strategyClassName) {
        if( StringUtils.isEmpty(strategyClassName) ) {
            return null;
        }
        ObjectMarshallingStrategy objectMarshallingStrategy = null;
        for( int i = 0; i < this.strategiesList.length; ++i ) {
           if( strategiesList[i].getClass().getName().equals(strategyClassName) ) {
               return strategiesList[i];
           }
        }
View Full Code Here

TOP

Related Classes of org.drools.marshalling.ObjectMarshallingStrategy

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.