reviewed annotation - fragna für toni
This commit is contained in:
parent
6289dc379c
commit
fddbe1f12c
|
@ -30,6 +30,7 @@
|
|||
\item @Resource
|
||||
\begin{itemize}
|
||||
\item fast wie Dependency Injection
|
||||
\item damit weiß der Container wie er das Annotierte Feld instanzieren muss
|
||||
\end{itemize}
|
||||
\item @Stateless
|
||||
\begin{itemize}
|
||||
|
@ -88,79 +89,41 @@
|
|||
|
||||
|
||||
\subsection{Annotationen - Details}
|
||||
\begin{itemize}
|
||||
\item CascadeType.Remove löscht die damit Annotierte Verknüpfung mit
|
||||
\item dies geht auch rekursiv in der kompletten Datenbank
|
||||
\item CascadeType.Remove und orphanRemoval=true ist equivalent
|
||||
\end{itemize}
|
||||
\begin{minted}[linenos,breaklines=true]{java}
|
||||
...
|
||||
@OneToOne(fetch = FetchType.EAGER,
|
||||
cascade = CascadeType.ALL,
|
||||
orphanRemoval = true)
|
||||
@JoinColumn(name = "documentlibrary_id")
|
||||
private Documentlibrary documentlibrary;
|
||||
|
||||
CascadeType anschauen
|
||||
|
||||
@Entity
|
||||
@Table(name = "user")
|
||||
public class User extends AbstractEntity {
|
||||
private static final long serialVersionUID = -7060150053795176748L;
|
||||
|
||||
@OneToMany(
|
||||
mappedBy = "communityAdminUser",
|
||||
cascade = {CascadeType.PERSIST, CascadeType.REFRESH}, // Persist Operation des User werden auch auf dessen communityAdminUser persistiert - und auch update
|
||||
orphanRemoval = true //
|
||||
@Column(nullable = false, unique = true)
|
||||
private String name;
|
||||
...
|
||||
public enum CascadeType {
|
||||
/* Cascade all operations /
|
||||
ALL,
|
||||
/* Cascade persist operation /
|
||||
PERSIST,
|
||||
/* Cascade merge operation /
|
||||
MERGE,
|
||||
/* Cascade remove operation /
|
||||
REMOVE,
|
||||
/* Cascade refresh operation /
|
||||
REFRESH,
|
||||
*/
|
||||
DETACH
|
||||
...
|
||||
}
|
||||
)
|
||||
\end{minted}
|
||||
|
||||
\section{Konfigurationsdateien}
|
||||
\subsection{standalone-psoe.xml}
|
||||
|
||||
Wird ein JBoss Applikationsserver im \emph{standalone}-Modus betrieben, läuft jede Instanz in einem eigenen Prozess.
|
||||
Diese Datei ist eine Java Enterprise Edition 6 zertifizierte Web-Profil Konfiguration welche alle benötigten Technologien (z.B. Extensions von JBoss, Datasources etc.) definiert.
|
||||
|
||||
JBoss EAP benutzt standardmäßig die standalone.xml Konfigurationsdatei, kann aber auch unter Verwendung einer anderen gestartet werden.
|
||||
|
||||
Abschnitte der standalone.xml
|
||||
\begin{itemize}
|
||||
\item extensions (z.B. diverse Wildfly Module)
|
||||
\item management (z.B. Access Control -> role-mapping)
|
||||
\item profile (z.B. JPA Subsystem)
|
||||
\item interfaces (z.B. \${jboss.bind.address:127.0.0.1})
|
||||
\item socket-binding-group (z.B \${jboss.http.port:8080})
|
||||
\item Rechte (Management-Realm)
|
||||
\item Datenbankzugriffsparameter
|
||||
\end{itemize}
|
||||
|
||||
\begin{code}
|
||||
\captionof{listing}{standalone.xml (auszugsweise)}
|
||||
|
||||
|
||||
\begin{minted}[linenos,breaklines=true]{xml}
|
||||
|
||||
........
|
||||
|
||||
</endpoint-config>
|
||||
<client-config name="Standard-Client-Config"/>
|
||||
</subsystem>
|
||||
<subsystem xmlns="urn:jboss:domain:weld:3.0"/>
|
||||
</profile>
|
||||
<interfaces>
|
||||
<interface name="management">
|
||||
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
|
||||
</interface>
|
||||
<interface name="public">
|
||||
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
|
||||
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
|
||||
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
|
||||
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
|
||||
<socket-binding name="http" port="${jboss.http.port:8080}"/>
|
||||
<socket-binding name="https" port="${jboss.https.port:8443}"/>
|
||||
<socket-binding name="txn-recovery-environment" port="4712"/>
|
||||
<socket-binding name="txn-status-manager" port="4713"/>
|
||||
<outbound-socket-binding name="mail-smtp">
|
||||
<remote-destination host="localhost" port="25"/>
|
||||
</outbound-socket-binding>
|
||||
</socket-binding-group>
|
||||
</server>
|
||||
|
||||
\end{minted}
|
||||
\end{code}
|
||||
|
||||
\subsection{persistence.xml}
|
||||
|
||||
Die Datei \emph{persistence.xml} ist der zentrale Bestandteil der Persistierungs-Konfiguration.
|
||||
|
@ -292,17 +255,64 @@ SQL stdout logging
|
|||
\label{fig:pom}
|
||||
\end{figure}
|
||||
|
||||
\section{Frageart Prüfung}
|
||||
Welche Fehler können bei Exception-Handling vorkommen in unserem Projekt?? – wie funktioniert es grundsätzlich in unserem Code
|
||||
\subsection{standalone-psoe.xml}
|
||||
|
||||
DocumentDAO – DocumentService – DocumentController – so sollte Exception-Handling implementiert warden
|
||||
Wird ein JBoss Applikationsserver im \emph{standalone}-Modus betrieben, läuft jede Instanz in einem eigenen Prozess.
|
||||
Diese Datei ist eine Java Enterprise Edition 6 zertifizierte Web-Profil Konfiguration welche alle benötigten Technologien (z.B. Extensions von JBoss, Datasources etc.) definiert.
|
||||
|
||||
DAO wirft Exception – im ServiceLayer wird dies gefangen und der Stack-Trace wird im weggeloggt und eine benutzerfreundliche Fehlermeldung wird ausgegeben (Destructive Wrapping).
|
||||
JBoss EAP benutzt standardmäßig die standalone.xml Konfigurationsdatei, kann aber auch unter Verwendung einer anderen gestartet werden.
|
||||
|
||||
Alle Patterns, die vorkommen – praktische Beispiele aus dem Code
|
||||
Abschnitte der standalone.xml
|
||||
\begin{itemize}
|
||||
\item extensions (z.B. diverse Wildfly Module)
|
||||
\item management (z.B. Access Control -> role-mapping)
|
||||
\item profile (z.B. JPA Subsystem)
|
||||
\item interfaces (z.B. \${jboss.bind.address:127.0.0.1})
|
||||
\item socket-binding-group (z.B \${jboss.http.port:8080})
|
||||
\item Rechte (Management-Realm)
|
||||
\item Datenbankzugriffsparameter
|
||||
\end{itemize}
|
||||
|
||||
Was sind JavaBeans? Wie funktioniert das Konzept? Wie wird es genau implementiert?
|
||||
NamedBean, TypedBean etc.
|
||||
\begin{code}
|
||||
\captionof{listing}{standalone.xml (auszugsweise)}
|
||||
|
||||
|
||||
\begin{minted}[linenos,breaklines=true]{xml}
|
||||
|
||||
........
|
||||
|
||||
</endpoint-config>
|
||||
<client-config name="Standard-Client-Config"/>
|
||||
</subsystem>
|
||||
<subsystem xmlns="urn:jboss:domain:weld:3.0"/>
|
||||
</profile>
|
||||
<interfaces>
|
||||
<interface name="management">
|
||||
<inet-address value="${jboss.bind.address.management:127.0.0.1}"/>
|
||||
</interface>
|
||||
<interface name="public">
|
||||
<inet-address value="${jboss.bind.address:127.0.0.1}"/>
|
||||
</interface>
|
||||
</interfaces>
|
||||
<socket-binding-group name="standard-sockets" default-interface="public" port-offset="${jboss.socket.binding.port-offset:0}">
|
||||
<socket-binding name="management-http" interface="management" port="${jboss.management.http.port:9990}"/>
|
||||
<socket-binding name="management-https" interface="management" port="${jboss.management.https.port:9993}"/>
|
||||
<socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
|
||||
<socket-binding name="http" port="${jboss.http.port:8080}"/>
|
||||
<socket-binding name="https" port="${jboss.https.port:8443}"/>
|
||||
<socket-binding name="txn-recovery-environment" port="4712"/>
|
||||
<socket-binding name="txn-status-manager" port="4713"/>
|
||||
<outbound-socket-binding name="mail-smtp">
|
||||
<remote-destination host="localhost" port="25"/>
|
||||
</outbound-socket-binding>
|
||||
</socket-binding-group>
|
||||
</server>
|
||||
|
||||
\end{minted}
|
||||
\end{code}
|
||||
|
||||
\subsection{log4j.properties}
|
||||
textit{src/test/resources/log4j.properties}
|
||||
|
||||
\section{Fehler im Projekt}
|
||||
\subsection{Return null}
|
||||
|
@ -472,5 +482,96 @@ public void saveUser(UserDTO userDTO) {
|
|||
\subsection{Integration}
|
||||
\subsection{Selenium bzw. GUI}
|
||||
|
||||
\section{Toni FRAAGNAA}
|
||||
Den Code durchgehen - was statt null - welche Exception - logger ok?
|
||||
ob ein Throw im try Block ok ist.
|
||||
\begin{minted}[linenos,breaklines=true]{java}
|
||||
|
||||
@Override
|
||||
public List<Document> findByUser(User user) {
|
||||
logger.debug("dao: documents findByUser");
|
||||
try {
|
||||
if(user == null) throw new IllegalArgumentException("user must not be null");
|
||||
return entityMangaer.createQuery("from Document d where d.user.userId = :userid", Document.class).setParameter("userid", user.getUserId()).getResultList();
|
||||
} catch(NoResultException noresex) {
|
||||
logger.info("dao: findByUser no documents found");
|
||||
return null;
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new DaoException("error finding documents of user",e);
|
||||
}
|
||||
}
|
||||
|
||||
// throw in try
|
||||
@Override
|
||||
public void delete(Document document) {
|
||||
logger.debug("dao: delete document");
|
||||
|
||||
try {
|
||||
if(document == null) throw new IllegalArgumentException("document must not be null");
|
||||
if(!entityMangaer.contains(document)) {
|
||||
document = entityMangaer.merge(document);
|
||||
}
|
||||
entityMangaer.remove(document);
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new DaoException("error deleting document",e);
|
||||
}
|
||||
}
|
||||
// ist loggen ohne stacktrace ok?
|
||||
@Override
|
||||
public TimeRecording getTimeRecordingByTask(Task task) {
|
||||
TimeRecording result = new TimeRecording();
|
||||
try {
|
||||
result = entityManager.createQuery("select t from TimeRecording t where t.task.id = :id", TimeRecording.class)
|
||||
.setParameter("id", task.getId()).getSingleResult();
|
||||
} catch (NoResultException e) {
|
||||
logger.warn("Not Possible to find TimeRecording with task id " + task.getId());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
// UserDTO - @XmlElement
|
||||
@XmlElement
|
||||
public void setPhoneNumber(String phoneNumber) {
|
||||
this.phoneNumber = phoneNumber;
|
||||
}
|
||||
// wos is produces
|
||||
@Override
|
||||
@Produces
|
||||
@Named("userPrincipal")
|
||||
@SessionScoped
|
||||
public UserPrincipal getUserPrincipal() {
|
||||
String principalName = sessionContext.getCallerPrincipal().getName();
|
||||
logger.info(principalName);
|
||||
try {
|
||||
User user = userDao.getByEmail(principalName);
|
||||
return new UserPrincipal(user.getId(), user.getUserId(), user.getEmail(), user.getFirstname(), user.getLastname());
|
||||
} catch (DaoException e) {
|
||||
logger.error("Error loading user '{}'", principalName, e);
|
||||
throw new ServiceException("Error loading user");
|
||||
} catch (Throwable e) {
|
||||
logger.error("Unknown error loading user '{}'", principalName, e);
|
||||
throw new ServiceException("Unknown error loading user");
|
||||
}
|
||||
// @Typed -> Zarwos
|
||||
|
||||
// warum immer mappedBy Mehrzahl
|
||||
@ManyToMany(mappedBy = "businessTrips")
|
||||
|
||||
// dependency Injection
|
||||
|
||||
// braucht man im Controller (ViewHelper) überhaupt noch Exception Handling
|
||||
|
||||
\end{minted}
|
||||
|
||||
\section{Frageart Prüfung}
|
||||
Welche Fehler können bei Exception-Handling vorkommen in unserem Projekt?? – wie funktioniert es grundsätzlich in unserem Code
|
||||
|
||||
DocumentDAO – DocumentService – DocumentController – so sollte Exception-Handling implementiert warden
|
||||
|
||||
DAO wirft Exception – im ServiceLayer wird dies gefangen und der Stack-Trace wird im weggeloggt und eine benutzerfreundliche Fehlermeldung wird ausgegeben (Destructive Wrapping).
|
||||
|
||||
Alle Patterns, die vorkommen – praktische Beispiele aus dem Code
|
||||
|
||||
Was sind JavaBeans? Wie funktioniert das Konzept? Wie wird es genau implementiert?
|
||||
NamedBean, TypedBean etc.
|
||||
|
|
Loading…
Reference in New Issue