01: package com.flexive.example.ejb;
02:
03: import com.flexive.example.shared.interfaces.EJBExample;
04: import com.flexive.example.shared.interfaces.EJBExampleLocal;
05: import com.flexive.shared.CacheAdmin;
06: import com.flexive.shared.exceptions.FxApplicationException;
07: import com.flexive.shared.search.FxFoundType;
08: import com.flexive.shared.search.query.SqlQueryBuilder;
09: import com.flexive.shared.structure.FxEnvironment;
10: import com.flexive.shared.structure.FxType;
11:
12: import javax.ejb.*;
13: import java.util.HashMap;
14: import java.util.Map;
15:
16: /**
17: * A demo EJB bean.
18: */
19: @Stateless(name="EJBExample")
20: @TransactionAttribute(TransactionAttributeType.SUPPORTS)
21: @TransactionManagement(TransactionManagementType.CONTAINER)
22: public class EJBExampleBean implements EJBExample, EJBExampleLocal {
23:
24: /**
25: * {@inheritDoc}
26: */
27: public Map<FxType, Integer> getInstanceCounts()
28: throws FxApplicationException {
29: final Map<FxType, Integer> result = new HashMap<FxType, Integer>();
30: final FxEnvironment environment = CacheAdmin.getEnvironment();
31: for (FxFoundType foundType : new SqlQueryBuilder()
32: .select("@pk").getResult().getContentTypes()) {
33: result.put(environment
34: .getType(foundType.getContentTypeId()), foundType
35: .getFoundEntries());
36: }
37: return result;
38: }
39: }
|