Revision: 278 http://mindtreeinsight.svn.sourceforge.net/mindtreeinsight/?rev=278&view=rev Author: bindul Date: 2011-08-16 06:14:37 +0000 (Tue, 16 Aug 2011)
Log Message: ----------- An idea of a context Added Paths: ----------- insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/Context.java insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/ContextFactory.java insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/internal/ImplementationLookup.java Added: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/Context.java =================================================================== --- insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/Context.java (rev 0) +++ insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/Context.java 2011-08-16 06:14:37 UTC (rev 278) @@ -0,0 +1,40 @@ +/* + * $HeadURL$ + * + * Copyright (c) 2011 MindTree Ltd. + * + * This file is part of Insight. + * + * Insight is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Insight is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Insight. If not, see <http://www.gnu.org/licenses/>. + */ +package com.mindtree.techworks.insight.core.api; + +/** + * A context defines the scope in which a <code>LogEventModel</code> lives and + * operations are performed on it. + * + * @todo add more documentation + * + * @since Insight 2.0 + * @author Bindul Bhowmik + */ +public interface Context { + + /** + * Returns an implementation specific ID of the context. + * + * @return The context ID + */ + public String getContextId (); +} Property changes on: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/Context.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + HeadURL Id Added: svn:eol-style + native Added: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/ContextFactory.java =================================================================== --- insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/ContextFactory.java (rev 0) +++ insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/ContextFactory.java 2011-08-16 06:14:37 UTC (rev 278) @@ -0,0 +1,85 @@ +/* + * $HeadURL$ + * + * Copyright (c) 2011 MindTree Ltd. + * + * This file is part of Insight. + * + * Insight is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Insight is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Insight. If not, see <http://www.gnu.org/licenses/>. + */ +package com.mindtree.techworks.insight.core.api; + +import com.mindtree.techworks.insight.core.api.internal.ImplementationLookup; + +/** + * @todo add documentation + * + * @since Insight 2.0 + * @author Bindul Bhowmik + */ +public abstract class ContextFactory { + + /** + * Internal lock for lookups + */ + private static final Object lock = new Object(); + + /** + * The cached instance of the context factory + */ + private static ContextFactory contextFactory; + + /** + * Returns the instance of the factory. Factory lookup can be configured + * using multiple ways documented in the class documentation of the factory. + * + * @return The instance of the <code>ContextFactory</code> + */ + public static ContextFactory getInstance() { + + if (null == contextFactory) { + synchronized (lock) { + if (null == contextFactory) { + ImplementationLookup<ContextFactory> lookup = new ImplementationLookup<ContextFactory>(); + contextFactory = lookup.newInstance(); + } + } + } + + // TODO Add null check and throw an exception + return contextFactory; + } + + /** + * Creates a new context instance. Creation of new instances of context is + * implementation dependent. In certain framework implementations like + * Insight desktop, multiple contexts can exist, however in others like in + * a web container the implementation may optionally limit creating a single + * context per HTTP user session. + * + * @return A context object + */ + public abstract Context createNewContext (); + + /** + * Looks up a context by the context ID. The lookup may be scoped, specially + * in a web application setting, where lookups may only succeed within the + * same HTTP user session. Lookup may also fail if the context is already + * destroyed. + * + * @param contextId The ID of the context being looked up + * @return The <code>Context</code> object if available in scope + */ + public abstract Context getContext (String contextId); +} Property changes on: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/ContextFactory.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + HeadURL Id Added: svn:eol-style + native Added: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/internal/ImplementationLookup.java =================================================================== --- insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/internal/ImplementationLookup.java (rev 0) +++ insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/internal/ImplementationLookup.java 2011-08-16 06:14:37 UTC (rev 278) @@ -0,0 +1,38 @@ +/* + * $HeadURL$ + * + * Copyright (c) 2011 MindTree Ltd. + * + * This file is part of Insight. + * + * Insight is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free + * Software Foundation, either version 3 of the License, or (at your option) + * any later version. + * + * Insight is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General + * Public License for more details. + * + * You should have received a copy of the GNU General Public License along with + * Insight. If not, see <http://www.gnu.org/licenses/>. + */ +package com.mindtree.techworks.insight.core.api.internal; + +/** + * @todo add documentation + * + * @since Insight 2.0 + * @author Bindul Bhowmik + */ +public class ImplementationLookup <T> { + + public T newInstance () { + + } + + public Class<T> getImplementationClass () { + + } +} Property changes on: insight-core/trunk/insight-core-api/src/main/java/com/mindtree/techworks/insight/core/api/internal/ImplementationLookup.java ___________________________________________________________________ Added: svn:mime-type + text/plain Added: svn:keywords + HeadURL Id Added: svn:eol-style + native This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ uberSVN's rich system and user administration capabilities and model configuration take the hassle out of deploying and managing Subversion and the tools developers use with it. Learn more about uberSVN and get a free download at: http://p.sf.net/sfu/wandisco-dev2dev _______________________________________________ MindTreeInsight-commits mailing list MindTreeInsight-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mindtreeinsight-commits