001 /* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 * 019 */ 020 021 package org.apache.directory.shared.ldap.message.spi; 022 023 024 import java.io.OutputStream; 025 import java.nio.ByteBuffer; 026 027 import org.apache.directory.shared.asn1.codec.stateful.StatefulEncoder; 028 029 030 /** 031 * Standard encoder service provider interface. BER encoders of ASN.1 compiler 032 * stubs are expected to implement this interface. 033 * 034 * @author <a href="mailto:dev@directory.apache.org"> Apache Directory Project</a> 035 * @version $Rev: 437007 $ 036 */ 037 public interface ProviderEncoder extends ProviderObject, StatefulEncoder 038 { 039 /** 040 * Encodes a compiler stub specific ASN.1 message envelope containment tree 041 * onto an output stream. 042 * 043 * @param lock 044 * lock object used to exclusively write to the output stream 045 * @param out 046 * the OutputStream to encode the message envelope onto. 047 * @param obj 048 * the top-level message envelope stub instance, i.e. for the 049 * Snacc4J service provider this would be an instance of the 050 * LDAPMessage compiler generated stub class. 051 * @throws ProviderException 052 * to indicate an error while attempting to encode the message 053 * envelope onto the output stream. Provider specific exceptions 054 * encountered while encoding can be held within this subclass 055 * of MultiException. 056 */ 057 void encodeBlocking( Object lock, OutputStream out, Object obj ) throws ProviderException; 058 059 060 /** 061 * Encodes a compiler stub specific ASN.1 message envelope containment tree 062 * into byte array. 063 * 064 * @param obj 065 * the top-level message envelope stub instance, i.e. for the 066 * Snacc4J service provider this would be an instance of the 067 * LDAPMessage compiler generated stub class. 068 * @return the encoded object in a byte buffer 069 * @throws ProviderException 070 * to indicate an error while attempting to encode the message 071 * envelope into a byte buffer. Provider specific exceptions 072 * encountered while encoding can be held within this subclass 073 * of MultiException. 074 */ 075 ByteBuffer encodeBlocking( Object obj ) throws ProviderException; 076 }