use of javax.ejb.Lock in project Payara by payara.
the class LockHandler method postProcessAnnotation.
/**
* Set the default value (from class type annotation) on all
* methods that don't have a value.
*/
public void postProcessAnnotation(AnnotationInfo ainfo, EjbContext ejbContext) throws AnnotationProcessorException {
EjbSessionDescriptor ejbDesc = (EjbSessionDescriptor) ejbContext.getDescriptor();
Class classAn = (Class) ainfo.getAnnotatedElement();
Lock lockAnn = (Lock) ainfo.getAnnotation();
// At this point, all method-level specific annotations have been processed.
// For non-private methods, find the ones from the EjbContext's
// component definition view that are declared on this class. This will correctly
// eliminate any overridden methods and provide the most-derived version of each.
// Use the Class's declared methods list to get the private methods.
List<Method> toProcess = new ArrayList<Method>();
for (Method m : ejbContext.getComponentDefinitionMethods()) {
if (classAn.equals(m.getDeclaringClass())) {
toProcess.add(m);
}
}
for (Method m : classAn.getDeclaredMethods()) {
if (Modifier.isPrivate(m.getModifiers())) {
toProcess.add(m);
}
}
for (Method m : toProcess) {
// descriptor, set it.
if (!matchesExistingReadOrWriteLockMethod(m, ejbDesc)) {
MethodDescriptor newMethodDesc = new MethodDescriptor(m);
if (lockAnn.value() == LockType.WRITE) {
ejbDesc.addWriteLockMethod(newMethodDesc);
} else {
ejbDesc.addReadLockMethod(newMethodDesc);
}
}
}
}
use of javax.ejb.Lock in project muikku by otavanopisto.
the class MaterialUnEmbedder method unembedWorkspaceMaterials.
@Lock
public void unembedWorkspaceMaterials(WorkspaceNode parentNode) throws DeusNexInternalException {
try {
loadHtmlMaterialPieces();
for (WorkspaceNode node : workspaceMaterialController.listWorkspaceNodesByParent(parentNode)) {
unembedWorkspaceNode(parentNode, node);
}
saveHtmlMaterialPieces();
} catch (XPathExpressionException | SAXException | IOException | ParserConfigurationException | TransformerException | WorkspaceMaterialContainsAnswersExeption e) {
throw new DeusNexInternalException(e.getClass().getName() + ": " + e.getMessage());
}
}
use of javax.ejb.Lock in project solr-document-store by DBCDK.
the class SolrIndexer method unitFor.
@Lock(LockType.READ)
public String unitFor(String pid) throws RepositoryException {
try (IRepositoryDAO dao = daoProvider.getRepository()) {
IRepositoryIdentifier id = dao.createIdentifier(pid);
if (!dao.hasObject(id)) {
throw new IllegalStateException("Doesn't have pid: " + pid);
}
if (dao.getObjectState(id) == IRepositoryDAO.State.DELETED) {
return null;
}
ISysRelationsStream relations = dao.getSysRelationsStream(id);
IRepositoryIdentifier unit = relations.getUnitFor();
return unit.toString();
}
}
use of javax.ejb.Lock in project solr-document-store by DBCDK.
the class SolrIndexer method buildDocuments.
@Lock(LockType.READ)
@SuppressFBWarnings(value = "ICAST_IDIV_CAST_TO_DOUBLE", justification = "trimming of number of digits for LogStash.Marker#append()")
public void buildDocuments(String pid, SolrIndexerJS jsWrapper, BiConsumer<String, SolrUpdaterCallback> function) throws Exception {
try (IRepositoryDAO dao = daoProvider.getRepository()) {
if (jsWrapper.isIndexableIdentifier(pid)) {
long starttime = System.nanoTime();
String trackingId = getTrackingId(dao, pid);
DBCTrackedLogContext.setTrackingId(trackingId);
String data = getObjectData(dao, pid);
SolrUpdaterCallback callback = new SolrUpdaterCallback(jsWrapper.getEnvironment(), trackingId, pid);
jsWrapper.createIndexData(dao, pid, data, callback, libraryRuleHandler);
documentsDeleted.inc(callback.getDeletedDocumentsCount());
documentsUpdated.inc(callback.getUpdatedDocumentsCount());
if (callback.getDeletedDocumentsCount() > 0 || callback.getUpdatedDocumentsCount() > 0) {
function.accept(data, callback);
} else {
log.info("Indexing {} skipped by javascript", pid);
}
long endtime = System.nanoTime();
log.info(LogAppender.getMarker(App.APP_NAME, pid, LogAppender.SUCCEDED).and(append("duration", ((endtime - starttime) / 10000L) / 100.0)).and(append("updates", callback.getUpdatedDocumentsCount())).and(append("deletes", callback.getDeletedDocumentsCount())), "Documents successfully build");
} else {
log.debug("object {} filtered", pid);
}
} catch (Exception ex) {
String error = String.format("Error calling indexing logic for '%s'", pid);
log.error(LogAppender.getMarker(App.APP_NAME, pid, LogAppender.FAILED), error);
throw ex;
} finally {
DBCTrackedLogContext.remove();
}
}
use of javax.ejb.Lock in project tomee by apache.
the class BeanContext method initDefaultLock.
private void initDefaultLock() {
if (!BeanType.SINGLETON.equals(this.componentType)) {
return;
}
final ArrayList<Class> classes = new ArrayList<>();
classes.addAll(businessRemotes);
classes.addAll(businessLocals);
classes.add(this.beanClass);
for (final Class c : classes) {
Lock lock = null;
try {
lock = (Lock) c.getAnnotation(Lock.class);
this.getSingleton().lockType = lock.value();
if (logger.isDebugEnabled()) {
logger.debug("Declared Lock for " + c.getName() + " is " + this.getSingleton().lockType);
}
} catch (final NullPointerException e) {
// Ignore
} catch (final Throwable e) {
logger.warning("Failed to determine from: " + lock);
}
}
if (logger.isDebugEnabled()) {
logger.debug("Default Lock for " + this.beanClass.getName() + " is " + this.getSingleton().lockType);
}
}
Aggregations