Singleton Pattern
Motivation
Sometimes it's important to have only one instance for a class. For example, in a system there should be only one window manager (or only a file system or only a print spooler). Usually singletons are used for centralized management of internal or external resources and they provide a global point of access to themselves.The singleton pattern is one of the simplest design patterns: it involves only one class which is responsible to instantiate itself, to make sure it creates not more than one instance; in the same time it provides a global point of access to that instance. In this case the same instance can be used from everywhere, being impossible to invoke directly the constructor each time.
Intent
- Ensure that only one instance of a class is created.
- Provide a global point of access to the object.
Implementation
The implementation involves a static member in the "Singleton" class, a private constructor and a static public method that returns a reference to the static member.The Singleton Pattern defines a getInstance operation which exposes the unique instance which is accessed by the clients. getInstance() is is responsible for creating its class unique instance in case it is not created yet and to return that instance.
class Singleton
{
private static Singleton instance;
private Singleton()
{
...
}
public static synchronized Singleton getInstance()
{
if (instance == null)
instance = new Singleton();
return instance;
}
...
public void doSomething()
{
...
}
}
|
The getInstance method is used also to provide a global point of access to the object and it can be used in the following manner:
Singleton.getInstance().doSomething(); |
Applicability & Examples
According to the definition the singleton pattern should be used when there must be exactly one instance of a class, and when it must be accessible to clients from a global access point. Here are some real situations where the singleton is used:Example 1 - Logger Classes
The Singleton pattern is used in the design of logger classes. This classes are ussualy implemented as a singletons, and provides a global logging access point in all the application components without being necessary to create an object each time a logging operations is performed.Example 2 - Configuration Classes
The Singleton pattern is used to design the classes which provides the configuration settings for an application. By implementing configuration classes as Singleton not only that we provide a global access point, but we also keep the instance we use as a cache object. When the class is instantiated( or when a value is read ) the singleton will keep the values in its internal structure. If the values are read from the database or from files this avoids the reloading the values each time the configuration parameters are used.Example 3 - Accesing resources in shared mode
It can be used in the design of an application that needs to work with the serial port. Let's say that there are many classes in the application, working in an multi-threading environment, which needs to operate actions on the serial port. In this case a singleton with synchronized methods could be used to be used to manage all the operations on the serial port.Example 4 - Factories implemented as Singletons
Let's assume that we design an application with a factory to generate new objects(Acount, Customer, Site, Address objects) with their ids, in an multithreading environment. If the factory is instantiated twice in 2 different threads then is possible to have 2 overlapping ids for 2 different objects. If we implement the Factory as a singleton we avoid this problem. Combining Abstract Factory or Factory Method and Singleton design patterns is a common practice.List Definition in SharePoint 2010
In this article I am going to explain how to create a SharePoint 2010 List
Definition using Visual Studio 2010.
Open Visual Studio 2010
à
Select File
à New
à Project.
Select the Visual C#
à SharePoint 2010 --> List Definition
project template.
Enter "MyList" in the Name textbox and click on OK.
In the SharePoint Configuration Wizard select "Deploy as farm solution" and
click on "Next".
Enter "MyList" in the What is the display
name of the list definition? Textbox.
Select "Custom List"
in the What is the type of the list definition? Drop-down box.
In the Solution Explorer, expand ListInstance1 and open the
Elements.xml file:
Within the ListInstance element change:
the Title attribute to MyList and change the TemplateType attribute to 10001.
the Title attribute to MyList and change the TemplateType attribute to 10001.
<?xml
version="1.0" encoding="utf-8"?>
<Elements
xmlns="http://schemas.microsoft.com/sharepoint/">
<ListInstance
Title="MyList"
OnQuickLaunch="TRUE"
TemplateType="10001"
Url="Lists/MyList-ListInstance1"
Description="My List Instance">
</ListInstance>
</Elements>
Now, open the Elements.xml file which is on the same level as ListDefinition1.
Within the ListTemplate element, change the Type attribute to “10001” and add the DisallowContentTypes=”FALSE” attribute, as shown below:
<?xml
version="1.0" encoding="utf-8"?>
<Elements
xmlns="http://schemas.microsoft.com/sharepoint/">
<!-- Do not change the value of the Name attribute below. If
it does not match the folder name of the List Definition project item, an error
will occur when the project is run.
-->
<ListTemplate
Name="ListDefinition1"
Type="10001"
BaseType="0"
DisallowContentTypes="FALSE"
OnQuickLaunch="TRUE"
SecurityBits="11"
Sequence="410"
DisplayName="MyList"
Description="My List Definition"
Image="/_layouts/images/itgen.png"/>
</Elements>
Insert the following xml into the top of the Elements
element in the Elements.xml file. This XML describes the MyList Item content
type the list will store.
<ContentType
ID="0x010089E3E6DB8C9B4B3FBB980447E313CE94"
Name="My List"
Group="Custom Content Types"
Description="My List content type."
Version="0">
<FieldRefs>
<FieldRef
ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" />
<FieldRef
ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" />
<FieldRef
ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}" />
<FieldRef
ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}" />
</FieldRefs>
</ContentType>
Insert the following xml into the top of the Elements
element in the Elements.xml file. This XML describes the Fields the MyList Item
content type uses.
<Field
Type="Note" DisplayName="Title" Required="FALSE" NumLines="6" RichText="FALSE" Sortable="FALSE" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" StaticName="Title" Name="Title" Group="Custom Columns" />
<Field
Type="Note"
DisplayName="ID"
Required="FALSE"
NumLines="6"
RichText="FALSE"
Sortable="FALSE"
ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" StaticName="ID" Name="ID" Group="Custom Columns" />
<Field
Type="Text"
DisplayName="Name"
Required="FALSE"
MaxLength="255"
ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}" StaticName="Name" Name="Name" Group="Custom Columns" />
<Field
Type="Text"
DisplayName="Course"
Required="FALSE"
MaxLength="255"
ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}" StaticName="Course" Name="Course" Group="Custom Columns" />
In the Solution Explorer, open Schema.xml
Add the EnableContentTypes=”TRUE” attribute to the List element inside of the Schema.xml file
Add the EnableContentTypes=”TRUE” attribute to the List element inside of the Schema.xml file
Insert the following XML into the ContentTypes element in
the schema.xml file. This XML describes the
MyList Item content type this list will store.
<ContentTypeRef
ID="0x010089E3E6DB8C9B4B3FBB980447E313CE94" />
<ContentTypes>
<ContentTypeRef
ID="0x010089E3E6DB8C9B4B3FBB980447E313CE94" />
<ContentTypeRef
ID="0x01">
<Folder
TargetName="Item" />
</ContentTypeRef>
<ContentTypeRef
ID="0x0120" />
</ContentTypes>
Insert the following XML into the Fields element. This XML
describes the fields the list will store. These are directly related to the
fields in the Content Type we added in the previous step.
<Fields>
<Field
Type="Note"
DisplayName="Title"
Required="FALSE"
NumLines="6"
RichText="FALSE" Sortable="FALSE" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" StaticName="Title" Name="Title" Group="Custom Columns" />
RichText="FALSE" Sortable="FALSE" ID="{fa564e0f-0c70-4ab9-b863-0177e6ddd247}" StaticName="Title" Name="Title" Group="Custom Columns" />
<Field
Type="Note"
DisplayName="ID"
Required="FALSE"
NumLines="6"
RichText="FALSE"
Sortable="FALSE"
ID="{cb55bba1-81a9-47b6-8e6c-6a7da1d25602}" StaticName="ID" Name="ID" Group="Custom Columns" />
<Field
Type="Text"
DisplayName="Name"
Required="FALSE"
MaxLength="255"
ID="{0248c82f-9136-4b3a-b802-d0b77280b3bc}" StaticName="Name" Name="Name" Group="Custom Columns" />
<Field
Type="Text"
DisplayName="Course"
Required="FALSE"
MaxLength="255"
ID="{aa4a82dd-5b32-4507-9874-4e1c7bca3279}" StaticName="Course" Name="Course" Group="Custom Columns" />
</Fields>
Insert the following XML into the ViewFields element in the
2nd view, BaseViewID="1":
<ViewFields>
<FieldRef
Name="Attachments"></FieldRef>
<FieldRef
Name="LinkTitle"></FieldRef>
<FieldRef
Name="Title"></FieldRef>
<FieldRef
Name="ID"></FieldRef>
<FieldRef
Name="Name"></FieldRef>
<FieldRef
Name="Course"></FieldRef>
</ViewFields>
Right click on the project and select
Deploy:
After deploying a List Definition, check this list in the
SharePoint 2010 Central Administration:
Go to Site Action
à
More Options…
You can see that your MyList template is created in the
Installed Items template:
50 SharePoint 2010 Interview Questions With Answers – IT Pro / Architect
SharePoint 2010 Interview Questions – IT Pro / Architect
Basic Intro SharePoint Architecture Questions1) What are Web Applications in SharePoint?
An IIS Web site created and used by SharePoint 2010. Saying an IIS virtual server is also an acceptable answer.
2) What is an application pool?
A group of one or more URLs that are served by a particular worker process or set of worker processes.
3) Why are application pools important?
They provide a way for multiple sites to run on the same server but still have their own worker processes and identity.
4) What are zones?
Different logical paths (URLs meaning) of gaining access to the same SharePoint Web application.
5) What are Web Application Policies?
Enables security policy for users at the Web application level, rather than at the site collection or site level. Importantly, they override all other security settings.
6) What is a site collection?
A site collection contains a top-level website and can contain one or more sub-sites web sites that have the same owner and share administration settings.
7) What are content databases?
A content database can hold all the content for one or more site collections.
8) What is a site?
A site in SharePoint contains Web pages and related assets such as lists, all hosted within a site collection.
9) What are My Sites?
Specialized SharePoint sites personalized and targeted for each user.
10) What is the difference between Classic mode authentication and Claims-based authentication?
As the name implies, classic authentication supports NT authentication types like Kerberos, NTLM, Basic, Digest, and anonymous. Claims based authentication uses claims identities against a against a trusted identity provider.
11) When would you use claims, and when would you use classic?
Classic is more commonly seen in upgraded 2007 environments whereas claims are the recommended path for new deployments.
12) Describe the potential components for both a single server, and multiple servers, potentially several tiered farms:
A single-server SharePoint Server 2010 environment leverages a built-in SQL Server 2008 Express database. The problems with this environment is scalability, not being able to install the with built-in database on a domain controller, the database cannot be larger than 4 GB, and you cannot use User Profile Synchronization in a single server with built-in database installation.
An example of a multiple tier farm would be a three-tier topology, considered one of the more efficient physical and logical layouts to supports scaling out or scaling up and provides better distribution of services across the member servers of the farm. This is considered a good architecture since one can add Web servers to the Web tier, add app servers to the application tier, and add database servers to the database tier.
SharePoint Backup and Restore Questions
13) What are some of the tools that can be used when backing up a SharePoint 2010 environment?
- SharePoint farm backup and recovery
- SQL Server
- System Center Data Protection Manager
System Center Data Protection Manager
Managed Metadata Questions
15) What is Managed Metadata?
Managed metadata is a hierarchical collection of centrally managed terms that you can define, and then use as attributes for items.
16) What are Terms and Term Sets?
A term is a word or a phrase that can be associated with an item. A term set is a collection of related terms.
17) How do Terms And Term Sets relate to Managed Metadata?
Managed metadata is a way of referring to the fact that terms and term sets can be created and managed independently from the columns themselves.
18) Are there different types of Term Sets?
There are Local Term Sets and Global Term Sets, one created within the context of a site collection and the other created outside the context of a site collection, respectively.
19) How are terms created and used?
There are several ways; however the most common is to use the Term Store Management Tool.
20) How is Managed Metadata, and the related Term technology used?
Through the UI, the most common use is through the managed metadata list column which allows you to specify the term set to use. It also related to searching and enhancing the user search experience.
Sandbox Solutions Questions
21) What is a sandboxed solution?
Components that are deployed to run within the sandboxed process rather than running in the production Internet Information Services (IIS) worker process.
22) What are some examples of things that might run within the SharePoint sandbox?
Any of the following are acceptable answers:
Web Parts
Event receivers
Feature receivers
Custom Microsoft SharePoint Designer workflow activities
Microsoft InfoPath business logic
others….
23) Why are sandboxed solutions used?
Primarily because they promote high layers of isolation. By default they run within a rights-restricted, isolated process based around Code Access Security (CAS). Isolation is possible to increase with activities like running the sandboxing service on only specific SharePoint 2010 servers.
SharePoint Search Questions
24) What is a content source in relation to SharePoint search? What’s the minimum amount of content sources?
A content source is a set of options that you can use to specify what type of content is crawled, what URLs to crawl, and how deep and when to crawl. You must create at least one content source before a crawl can occur.
25) What is a search scope?
A search scope defines a subset of information in the search index. Users can select a search scope when performing a search.
26) What is a federated location with SharePoint search?
Federated locations provide information that exists outside of your internal network to your end-users.
27) How does managed metadata affect search?
Enhances the end-user search experience by mapping crawled properties to managed properties. Managed properties show up in search results and help users perform more successful queries.
28) What is query logging in SharePoint 2010?
Collects information about user search queries and search results that users select on their computers to improve the relevancy of search results and to improve query suggestions.
29) What authentication type does the SharePoint crawler use?
The crawl component requires access to content using NTLM authentication.
Services Architecture Questions
30) Please describe what a Service Application is in SharePoint 2010.
Service applications in SharePoint 2010 are a set of services that can possibly be shared across Web applications. Some of these services may or may not be shared across the SharePoint 2010 farm. The reason these applications are shared is the overall reduction of resources required to supply the functionality these services cultivate.
31) Please provide an example of one of these service applications.
Any of the below are acceptable answers:
Access Services
Business Data Connectivity service
Excel Services Application
Managed Metadata service
PerformancePoint Service Application
Search service
Secure Store Service
State service
Usage and Health Data Collection service
User Profile service
Visio Graphics Service
Web Analytics service
Word Automation Services
Microsoft SharePoint Foundation Subscription Settings Service
32) What are Service Application Groups used for?
Just provides a logical grouping of services that are scoped to a particular Web Application.
33) How are Service Applications deployed in terms of IIS (Internet Information Services)?
They are provisioned as a single Internet Information Services (IIS) Web site.
34) Explain how connections are managed with Service Applications.
A virtual entity is used that is referred to as a proxy, due to label in PowerShell.
35) What are some common examples of SharePoint 2010 services architectures, and what are the advantages of each design?
The three most popular designs are single farms with either a single service application group or multiple service application groups, or Enterprise services farms.
Single farms with a single service application group are generally the most common, and have the advantages of easy deployment, simple service application allocation, effective resource utilization and cohesive management.
Single farms with multiple service application groups is less common, and have the advantage of potential individual management of service applications as well as allowing data isolation, and while being more complex to deploy and maintain allows targeting of sites to particular service applications.
Enterprise Service Farms is pretty uncommon as it is a complete farm dedicated to Service Applications but promotes autonomous management and high levels of data isolation.
36) Are there any other type of relevant service architectures?
Depending on the environment requirements, a specialized farm can also be used in order to deploy specific services tailored to the organizational requirements which can aid in scaling out and conservation of resources.
37) What is the User Profile service?
Allows configuring and managing User profile properties, Audiences, Profile synchronization settings, organization browsing and management settings, and My Site settings.
38) What are User Profiles?
Aggregates properties from diverse identity content sources together to create unified and consistent profiles across an organization, used throughout the SharePoint environment.
39) What is Excel Services?
Allows sharing, securing, managing, and using Excel 2010 workbooks in a SharePoint Server Web site or document library. Excel Services consists of the Excel Calculation Services (ECS), Microsoft Excel Web Access (EWA), and Excel Web Services (EWS) components.
40) What is PerformancePoint Services?
Allows users to monitor and analyze a business by building dashboards, scorecards, and key performance indicators (KPIs).
41) What is Visio Services?
Allows users to share and view Microsoft Visio Web drawings. The service also enables data-connected Microsoft Visio 2010 Web drawings to be refreshed and updated from various data sources.
42) What is Access Services?
Allows users to edit, update, and create linked Microsoft Access 2010 databases that can be viewed and manipulated by using an internet browser, the Access client, or a linked HTML page.
43) What is the Secure Store Service (SSS)?
A secure database for storing credentials that are associated with application IDs
44) What is Content Deployment?
Content deployment enables you to copy content from a source site collection to a destination site collection.
Backup / DR Questions
45) Describe how redundancy can be built into a SharePoint environment. Please be specific in regards to any auxiliary components.
Multiple front-end web servers (WFE’s) can be deployed and correlated through Windows NLB or anything approach. Application servers can be deployed into the farm for a variety of purposes, depending on organizational requirements. Databases can be clustered or mirrored, again depending on requirements and environment.
46) From a basic standpoint, what is the difference between SQL clustering and mirroring?
Clustering provides a failover scenario whereby one or more nodes can be swapped as active depending on whether a node goes down. In mirroring, transactions are sent directly from a principal database and server to a mirror database to establish essentially a replica of the database.
Governance Questions
47) What Is Governance in terms of SharePoint 2010?
Governance is the set of policies, roles, responsibilities, and processes that guide, direct, and control how an organization’s business divisions and IT teams cooperate to achieve business goals.
48) What are some useful, OOB features of SharePoint that aid with governance of an environment?
Any of the below are acceptable answers. There are some others but these are the major ones that I generally look for from a candidate:
Site templates – consistent branding, site structure, and layout can be enforce a set of customizations that are applied to a site definition.
Quotas – limits to the amount of storage a site collection can use.
Locks - prevent users from either adding content to a site collection or using the site collection.
Web application permissions and policies – comprehensive security settings that apply to all users and groups for all site collections within a Web application.
Self-service site creation - enables users to create their own site collections, thus must be incorporated into a governance scheme.
Monitoring Questions
49) Describe the monitoring features that are baked into SharePoint 2010.
Diagnostic logging captures data about the state of the system, whereas health and usage data collection uses specific timer jobs to perform monitoring tasks, collecting information about:
- Performance Counter Fata
- Event Log Data
- Timer Service Data
- Metrics For Site Collections and Sites
- Search Usage Data
50) What is a declarative workflow? Can non-authenticated users participate in workflows?
Workflows created by using Microsoft SharePoint Designer 2010, the default setting enables deployment of declarative workflows. Yes, however you do not give non-authorized users access to the site. The e-mail message and attachments sent from notifications might contain sensitive information
Search Service Configuration (Part 1)
[How to stop ?? admin content search through service]
I was reported some issue in one for my SharePoint project by client, it's regarding to the search functionality it said "the search function is displaying as a default search result. i.e. it is displaying admin section also."
. what they mentioned is when they search something they get result
which also related to the Admin section also like Central Administrator
or other test sites.
this project we have used default search web parts and core result web
parts to get and show the search results. means we cannot do many
changes in web part levels. so what we need to do is, Looking at the
search configuration.
Who Responsible .....
Service applications are responsible for many SharePoint services which
provide through the framework. when you consider on search basically
it's Search Service Application. so if you have a search service
application then you get at-least something for search result when you
search something . if you don't then you'll get something like following
image, with error massage "The search request was unable to connect to the Search
Service." when you search.
so if you don't have one just create one.
How To Create ...
Login to central admin using the farm admin credential Access to
“Manage service applications” under “Application Management” .
Then click on new and select Search Service application.
Then Fill the required field in the popup. Give name as a Search Service
Application (you can give any name you like, but this is much
professional).
you need to do some configurations, under the "Application Pool for Search Admin Web Service" and "Application Pool for Search Query and Site Settings Web Service".
You can configure these section with new application pool or
chose existing one (I recommend to chose existing one to eliminate
configuration errors.).
Then click OK, you get loading popup once it's creating.
Once it done you can search through the SharePoint Application but still
that's not our main issue. Ore issue is how to stop getting Admin
Content Search Results.
ISSUE ....
The issue is on the search configuration (Central Admin level). The
default configuration is (eg: All Site or Advanced Search) to get all
the result related for the farm level that’s why you get all result
including Admin level.
SOLUTION ...
To solve this issue we need to configure search service application and edit the Local SharePoint Site list.
for that we need to navigate to the Local SharePoint Site List .
Go to The Manage service Applications (I explain the path above). then click Search Service Application.
Click on “Content Sources” under “Crawling” in the left navigation
Click on the dropdown arrow “Local SharePoint sites” and click “Edit”

Under “Type start addresses below (one per line):” section you can see
all the site URLs including admin level URLs also configured.
Ensure the following values are set.
• Remove all the URLs which already configured,
• Give both <site> URL and the <anonymous site> URL as the “Start Address”
• For the schedule of “Full crawl” and “Incremental crawl”, click on “Edit Schedule” and use the default and click OK [Scheduling part is optional you can schedule it or keep it as none for both Full Crawl and Incremental Crawl ]
At the end of this process start full crawl of this content source.
Click on the dropdown arrow “Local SharePoint sites” and click “Start
Full Crawl”
Wait until the status part is “complete”. Then go to the application and
Search something. It will only give the Site or Application Contents.












No comments:
Post a Comment