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

E47891-01

coherence/io/pof/SystemPofContext.hpp

00001 /*
00002 * SystemPofContext.hpp
00003 *
00004 * Copyright (c) 2000, 2014, 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/SimplePofContext.hpp"
00024 #include "coherence/io/pof/TypedSerializer.hpp"
00025 
00026 COH_OPEN_NAMESPACE3(coherence,io,pof)
00027 
00028 
00029 /**
00030 * System-wide PofContext implementation that allows POF user types to
00031 * be registered programatically.
00032 *
00033 * @author jh  2008.02.21
00034 */
00035 class COH_EXPORT SystemPofContext
00036     : public cloneable_spec<SystemPofContext,
00037         extends<SimplePofContext> >
00038     {
00039     friend class factory<SystemPofContext>;
00040 
00041     // ----- constructors ---------------------------------------------------
00042 
00043     public:
00044         /**
00045         * @internal
00046         */
00047         using this_spec::create;
00048 
00049     private:
00050         /**
00051         * @internal
00052         */
00053         SystemPofContext();
00054 
00055         /**
00056         * Copy constructor.
00057         */
00058         SystemPofContext(const SystemPofContext& that);
00059 
00060 
00061     public:
00062         /**
00063         * Return the SystemPofContext singleton instance.
00064         *
00065         * @return the global SystemPofContext
00066         */
00067         static Handle getInstance();
00068 
00069         /**
00070         * Executable entrypoint for the SystemPofContext class.
00071         *
00072         * Print the POF registrations.
00073         *
00074         * @param vasArg  a list of libraries to load, and print their
00075         *                registered classes.
00076         */
00077         static void main(ObjectArray::View vasArg);
00078     };
00079 
00080 
00081 // ----- helper macros ------------------------------------------------------
00082 
00083 /**
00084 * Register a PofSerializer with the system PofContext. The call will also
00085 * register the class with the SystemClassLoader.
00086 *
00087 * @param POF_TYPE_ID     the POF type identifier
00088 * @param CLASS           the associated class to register
00089 * @param POF_SERIALIZER  the PofSerializer instance to register
00090 */
00091 #define COH_REGISTER_POF_SERIALIZER(POF_TYPE_ID, CLASS, POF_SERIALIZER) \
00092     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()-> \
00093         registerUserType(POF_TYPE_ID, \
00094             coherence::lang::SystemClassLoader::getInstance()-> \
00095             registerClass(CLASS), POF_SERIALIZER))
00096 
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, coherence::io::pof::SystemPofContext::getInstance()-> \
00107         registerUserType(POF_TYPE_ID, s_coh_static_class_##TYPE, \
00108         coherence::io::pof::PortableObjectSerializer::create(POF_TYPE_ID)))
00109 
00110 /**
00111 * Register a PortableObject implementation with the system ClassLoader and
00112 * PofContext.
00113 *
00114 * @param POF_TYPE_ID  the POF type identifier
00115 * @param TYPE         the class type to register
00116 */
00117 #define COH_REGISTER_PORTABLE_CLASS(POF_TYPE_ID, TYPE) \
00118     COH_REGISTER_TYPED_CLASS(TYPE); \
00119     COH_REGISTER_ONLY_PORTABLE_CLASS(POF_TYPE_ID, TYPE)
00120 
00121 /**
00122 * Register a Managed object implementation with the system ClassLoader and
00123 * PofContext.
00124 *
00125 * @param POF_TYPE_ID  the POF type identifier
00126 * @param TYPE         the class type to register
00127 */
00128 #define COH_REGISTER_MANAGED_CLASS(POF_TYPE_ID, TYPE) \
00129     COH_REGISTER_NAMED_CLASS(TYPE, \
00130         coherence::lang::TypedClass<coherence::lang::Managed<TYPE > >::create()); \
00131     COH_STATIC_INIT_EX(1, coherence::io::pof::SystemPofContext::getInstance()-> \
00132         registerUserType(POF_TYPE_ID, s_coh_static_class_##TYPE, \
00133         coherence::io::pof::TypedSerializer<coherence::lang::Managed<TYPE > >::create()))
00134 
00135 
00136 /**
00137 * Register an annotated class with the system ClassLoader and PofContext. The
00138 * Class (TYPE) must be registered with the SystemClassLoader, which is
00139 * assumed based on this being a pre-requisite to adding annotations, and have
00140 * a coherence::io::pof::Portable annotation present.
00141 *
00142 * @param POF_TYPE_ID  the POF type identifier
00143 * @param TYPE         the class type to register
00144 */
00145 #define COH_REGISTER_POF_ANNOTATED_CLASS(POF_TYPE_ID, TYPE)                 \
00146     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()->   \
00147         registerUserType(POF_TYPE_ID,                                       \
00148             coherence::lang::SystemClassLoader::getInstance()->             \
00149             loadByType(typeid(TYPE)),                                       \
00150             coherence::io::pof::PofAnnotationSerializer::create(POF_TYPE_ID,\
00151                        coherence::lang::SystemClassLoader::getInstance()->  \
00152                            loadByType(typeid(TYPE)))))                      \
00153 
00154 /**
00155 * Register an annotated class with the system ClassLoader and PofContext. The
00156 * Class (TYPE) must be registered with the SystemClassLoader, which is
00157 * assumed based on this being a pre-requisite to adding annotations, and have
00158 * a coherence::io::pof::Portable annotation present. This macro additionally
00159 * suggests to the serializer to determine portable property indexes.
00160 *
00161 * @param POF_TYPE_ID  the POF type identifier
00162 * @param TYPE         the class type to register
00163 */
00164 #define COH_REGISTER_POF_ANNOTATED_CLASS_AI(POF_TYPE_ID, TYPE)              \
00165     COH_STATIC_INIT(coherence::io::pof::SystemPofContext::getInstance()->   \
00166         registerUserType(POF_TYPE_ID,                                       \
00167             coherence::lang::SystemClassLoader::getInstance()->             \
00168             loadByType(typeid(TYPE)),                                       \
00169             coherence::io::pof::PofAnnotationSerializer::create(POF_TYPE_ID,\
00170                        coherence::lang::SystemClassLoader::getInstance()->  \
00171                            loadByType(typeid(TYPE)), true)))                \
00172 
00173 COH_CLOSE_NAMESPACE3
00174 
00175 #endif // COH_SYSTEM_POF_CONTEXT_HPP
Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.