Oracle® Fusion Middleware C++ API Reference for Oracle Coherence
12c (12.2.1.3.0)

E80355-01

coherence/io/pof/SystemPofContext.hpp

00001 /*
00002 * SystemPofContext.hpp
00003 *
00004 * Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.
00005 *
00006 * Oracle is a registered trademarks of Oracle Corporation and/or its
00007 * affiliates.
00008 *
00009 * This software is the confidential and proprietary information of Oracle
00010 * Corporation. You shall not disclose such confidential and proprietary
00011 * information and shall use it only in accordance with the terms of the
00012 * license agreement you entered into with Oracle.
00013 *
00014 * This notice may not be removed or altered.
00015 */
00016 #ifndef COH_SYSTEM_POF_CONTEXT_HPP
00017 #define COH_SYSTEM_POF_CONTEXT_HPP
00018 
00019 #include "coherence/lang.ns"
00020 
00021 #include "coherence/io/pof/PofAnnotationSerializer.hpp"
00022 #include "coherence/io/pof/PortableObjectSerializer.hpp"
00023 #include "coherence/io/pof/PortableTypeSerializer.hpp"
00024 #include "coherence/io/pof/SimplePofContext.hpp"
00025 #include "coherence/io/pof/TypedSerializer.hpp"
00026 
00027 COH_OPEN_NAMESPACE3(coherence,io,pof)
00028 
00029 
00030 /**
00031 * System-wide PofContext implementation that allows POF user types to
00032 * be registered programmatically.
00033 *
00034 * @author jh  2008.02.21
00035 */
00036 class COH_EXPORT SystemPofContext
00037     : public cloneable_spec<SystemPofContext,
00038         extends<SimplePofContext> >
00039     {
00040     friend class factory<SystemPofContext>;
00041 
00042     // ----- constructors ---------------------------------------------------
00043 
00044     public:
00045         /**
00046         * @internal
00047         */
00048         using this_spec::create;
00049 
00050     private:
00051         /**
00052         * @internal
00053         */
00054         SystemPofContext();
00055 
00056         /**
00057         * Copy constructor.
00058         */
00059         SystemPofContext(const SystemPofContext& that);
00060 
00061 
00062     public:
00063         /**
00064         * Return the SystemPofContext singleton instance.
00065         *
00066         * @return the global SystemPofContext
00067         */
00068         static Handle getInstance();
00069 
00070         /**
00071         * Executable entrypoint for the SystemPofContext class.
00072         *
00073         * Print the POF registrations.
00074         *
00075         * @param vasArg  a list of libraries to load, and print their
00076         *                registered classes.
00077         */
00078         static void main(ObjectArray::View vasArg);
00079     };
00080 
00081 
00082 // ----- helper macros ------------------------------------------------------
00083 
00084 /**
00085 * Register a PofSerializer with the system PofContext. The call will also
00086 * register the class with the SystemClassLoader.
00087 *
00088 * @param POF_TYPE_ID     the POF type identifier
00089 * @param CLASS           the associated class to register
00090 * @param POF_SERIALIZER  the PofSerializer instance to register
00091 */
00092 #define COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, CLASS, POF_SERIALIZER)     \
00093     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()->   \
00094         registerUserType(POF_TYPE_ID,                                       \
00095             coherence::lang::SystemClassLoader::getInstance()->             \
00096             registerClass(CLASS), POF_SERIALIZER))
00097 
00098 /**
00099 * Register a PortableObject implementation only with the system PofContext.
00100 * The class must have already been registered with the SystemClassLoader.
00101 *
00102 * @param POF_TYPE_ID  the POF type identifier
00103 * @param TYPE         the class type to register
00104 */
00105 #define COH_REGISTER_ONLY_PORTABLE_CLASS(POF_TYPE_ID, TYPE)                 \
00106     COH_STATIC_INIT_EX(1,                                                   \
00107         coherence::io::pof::SystemPofContext::getInstance()->               \
00108             registerUserType(POF_TYPE_ID, s_coh_static_class_##TYPE,        \
00109                 coherence::io::pof::PortableObjectSerializer::create(POF_TYPE_ID)))
00110 
00111 /**
00112 * Register a PortableObject implementation with the system ClassLoader and
00113 * PofContext.
00114 *
00115 * @param POF_TYPE_ID  the POF type identifier
00116 * @param TYPE         the class type to register
00117 */
00118 #define COH_REGISTER_PORTABLE_CLASS(POF_TYPE_ID, TYPE)                      \
00119     COH_REGISTER_TYPED_CLASS(TYPE);                                         \
00120     COH_REGISTER_ONLY_PORTABLE_CLASS(POF_TYPE_ID, TYPE)
00121 
00122 /**
00123 * Register a Managed object implementation with the system ClassLoader and
00124 * PofContext.
00125 *
00126 * @param POF_TYPE_ID  the POF type identifier
00127 * @param TYPE         the class type to register
00128 */
00129 #define COH_REGISTER_MANAGED_CLASS(POF_TYPE_ID, TYPE)                       \
00130     COH_REGISTER_NAMED_CLASS(TYPE,                                          \
00131         coherence::lang::TypedClass<coherence::lang::Managed<TYPE > >::create()); \
00132     COH_STATIC_INIT_EX(1, coherence::io::pof::SystemPofContext::getInstance()->   \
00133         registerUserType(POF_TYPE_ID, s_coh_static_class_##TYPE,            \
00134         coherence::io::pof::TypedSerializer<coherence::lang::Managed<TYPE > >::create()))
00135 
00136 /**
00137 * Register a PortableObject implementation to use the PortableTypeSerializer
00138 * only with the system PofContext. The class must have already been registered
00139 * with the SystemClassLoader.
00140 *
00141 * @param POF_TYPE_ID  the POF type identifier
00142 * @param TYPE         the class type to register
00143 */
00144 #define COH_REGISTER_ONLY_PORTABLE_TYPE_CLASS(POF_TYPE_ID, TYPE)            \
00145     COH_STATIC_INIT_EX(1,                                                   \
00146         coherence::io::pof::SystemPofContext::getInstance()->               \
00147         registerUserType(POF_TYPE_ID, s_coh_static_class_##TYPE,            \
00148         coherence::io::pof::PortableTypeSerializer::create(POF_TYPE_ID)))
00149 
00150 /**
00151 * Register a PortableObject to use the PortableTypeSerializer implementation
00152 * with the system ClassLoader and PofContext.
00153 *
00154 * @param POF_TYPE_ID  the POF type identifier
00155 * @param TYPE         the class type to register
00156 */
00157 #define COH_REGISTER_PORTABLE_TYPE_CLASS(POF_TYPE_ID, TYPE)                 \
00158     COH_REGISTER_TYPED_CLASS(TYPE);                                         \
00159     COH_REGISTER_ONLY_PORTABLE_TYPE_CLASS(POF_TYPE_ID, TYPE)
00160 
00161 /**
00162 * Register an annotated class with the system ClassLoader and PofContext. The
00163 * Class (TYPE) must be registered with the SystemClassLoader, which is
00164 * assumed based on this being a pre-requisite to adding annotations, and have
00165 * a coherence::io::pof::Portable annotation present.
00166 *
00167 * @param POF_TYPE_ID  the POF type identifier
00168 * @param TYPE         the class type to register
00169 */
00170 #define COH_REGISTER_POF_ANNOTATED_CLASS(POF_TYPE_ID, TYPE)                 \
00171     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()->   \
00172         registerUserType(POF_TYPE_ID,                                       \
00173             coherence::lang::SystemClassLoader::getInstance()->             \
00174             loadByType(typeid(TYPE)),                                       \
00175             coherence::io::pof::PofAnnotationSerializer::create(POF_TYPE_ID,\
00176                        coherence::lang::SystemClassLoader::getInstance()->  \
00177                            loadByType(typeid(TYPE)))))
00178 
00179 /**
00180 * Register an annotated class with the system ClassLoader and PofContext. The
00181 * Class (TYPE) must be registered with the SystemClassLoader, which is
00182 * assumed based on this being a pre-requisite to adding annotations, and have
00183 * a coherence::io::pof::Portable annotation present. This macro additionally
00184 * suggests to the serializer to determine portable property indexes.
00185 *
00186 * @param POF_TYPE_ID  the POF type identifier
00187 * @param TYPE         the class type to register
00188 */
00189 #define COH_REGISTER_POF_ANNOTATED_CLASS_AI(POF_TYPE_ID, TYPE)              \
00190     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()->   \
00191         registerUserType(POF_TYPE_ID,                                       \
00192             coherence::lang::SystemClassLoader::getInstance()->             \
00193             loadByType(typeid(TYPE)),                                       \
00194             coherence::io::pof::PofAnnotationSerializer::create(POF_TYPE_ID,\
00195                        coherence::lang::SystemClassLoader::getInstance()->  \
00196                            loadByType(typeid(TYPE)), true)))
00197 
00198 COH_CLOSE_NAMESPACE3
00199 
00200 #endif // COH_SYSTEM_POF_CONTEXT_HPP
Copyright © 2000, 2017, Oracle and/or its affiliates. All rights reserved.