Skip to content

Commit

Permalink
HSEARCH-1427 Reformat code to use line width of renderable page
Browse files Browse the repository at this point in the history
  • Loading branch information
Sanne committed Oct 7, 2013
1 parent b1a6fd7 commit 4e1696a
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions documentation/src/main/docbook/en-US/modules/advanced-features.xml
Expand Up @@ -210,33 +210,35 @@ finally {

<programlisting>public static class AnimalShardIdentifierProvider extends ShardIdentifierProviderTemplate {

@Override
public String getShardIdentifier(Class&lt;?&gt; entityType, Serializable id, String idAsString, Document document) {
if ( entityType.equals( Animal.class ) ) {
String type = document.getFieldable( "type" ).stringValue();
addShard( type );
return type;
}
throw new RuntimeException( "Animal expected but found " + entityType );
@Override
public String getShardIdentifier(Class&lt;?&gt; entityType, Serializable id,
String idAsString, Document document) {
if ( entityType.equals(Animal.class) ) {
String type = document.getFieldable("type").stringValue();
addShard(type);
return type;
}

@Override
protected Set&lt;String&gt; loadInitialShardNames(Properties properties, BuildContext buildContext) {
ServiceManager serviceManager = buildContext.getServiceManager();
SessionFactory sessionFactory = serviceManager.requestService( HibernateSessionFactoryServiceProvider.class, buildContext );
Session session = sessionFactory.openSession();
try {
Criteria initialShardsCriteria = session.createCriteria( Animal.class );
initialShardsCriteria.setProjection( Projections.distinct( Property.forName( "type" ) ) );

@SuppressWarnings("unchecked")
List&lt;String&gt; initialTypes = initialShardsCriteria.list();
return new HashSet&lt;String&gt;( initialTypes );
}
finally {
session.close();
}
throw new RuntimeException("Animal expected but found " + entityType);
}

@Override
protected Set&lt;String&gt; loadInitialShardNames(Properties properties, BuildContext buildContext) {
ServiceManager serviceManager = buildContext.getServiceManager();
SessionFactory sessionFactory = serviceManager.requestService(
HibernateSessionFactoryServiceProvider.class, buildContext);
Session session = sessionFactory.openSession();
try {
Criteria initialShardsCriteria = session.createCriteria(Animal.class);
initialShardsCriteria.setProjection( Projections.distinct(Property.forName("type")));

@SuppressWarnings("unchecked")
List&lt;String&gt; initialTypes = initialShardsCriteria.list();
return new HashSet&lt;String&gt;(initialTypes);
}
finally {
session.close();
}
}
}</programlisting>
</example>The are several things happening in
<classname>AnimalShardIdentifierProvider</classname>. First off its
Expand Down

0 comments on commit 4e1696a

Please sign in to comment.